Current location

narf Source control manager Git

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2016-03-12 15:22:52 -0800
committerChristopher Allan Webber <cwebber@dustycloud.org>2016-03-26 11:39:07 -0700
commit90779509bbe65ab56dd137ffb9d5019f498e79e1 (patch)
tree137dd5f06fd36768d35550d86d11d86a16d99d53
parentc9ab4b8adb7c2c493f711fa60b1d590b583b973d (diff)
Blog media type initial migration.
* mediagoblin/media_types/blog/migrations/562bc42a8fff_blog_media_type_initial_migration.py: New file.
-rw-r--r--mediagoblin/media_types/blog/migrations/562bc42a8fff_blog_media_type_initial_migration.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/mediagoblin/media_types/blog/migrations/562bc42a8fff_blog_media_type_initial_migration.py b/mediagoblin/media_types/blog/migrations/562bc42a8fff_blog_media_type_initial_migration.py
new file mode 100644
index 00000000..cfd9ef6c
--- /dev/null
+++ b/mediagoblin/media_types/blog/migrations/562bc42a8fff_blog_media_type_initial_migration.py
@@ -0,0 +1,59 @@
+"""Blog media type initial migration
+
+Revision ID: 562bc42a8fff
+Revises: 52bf0ccbedc1
+Create Date: 2016-03-12 23:17:45.477894
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '562bc42a8fff'
+down_revision = '52bf0ccbedc1'
+branch_labels = ('blog_media_type',)
+depends_on = None
+
+from alembic import op
+import sqlalchemy as sa
+
+
+def upgrade():
+ if op.get_bind().engine.has_table("blogpost__mediadata"):
+ # Skip; this has already been instantiated
+ # (probably via sqlalchemy-migrate)
+ return
+
+ op.create_table(
+ 'mediatype__blogs',
+ sa.Column('id', sa.Integer(), nullable=False),
+ sa.Column('title', sa.Unicode(), nullable=True),
+ sa.Column('description', sa.UnicodeText(), nullable=True),
+ sa.Column('author', sa.Integer(), nullable=False),
+ sa.Column('created', sa.DateTime(), nullable=False),
+ sa.Column('slug', sa.Unicode(), nullable=True),
+ sa.ForeignKeyConstraint(['author'], ['core__users.id']),
+ sa.PrimaryKeyConstraint('id'))
+
+ op.create_index(
+ op.f('ix_mediatype__blogs_author'),
+ 'mediatype__blogs', ['author'], unique=False)
+
+ op.create_index(
+ op.f('ix_mediatype__blogs_created'),
+ 'mediatype__blogs', ['created'], unique=False)
+
+ op.create_table(
+ 'blogpost__mediadata',
+ sa.Column('media_entry', sa.Integer(), nullable=False),
+ sa.Column('blog', sa.Integer(), nullable=False),
+ sa.ForeignKeyConstraint(['blog'], ['mediatype__blogs.id']),
+ sa.ForeignKeyConstraint(['media_entry'], ['core__media_entries.id']),
+ sa.PrimaryKeyConstraint('media_entry'))
+
+
+def downgrade():
+ op.drop_table('blogpost__mediadata')
+ op.drop_index(op.f('ix_mediatype__blogs_created'),
+ table_name='mediatype__blogs')
+ op.drop_index(op.f('ix_mediatype__blogs_author'),
+ table_name='mediatype__blogs')
+ op.drop_table('mediatype__blogs')