aboutsummaryrefslogtreecommitdiffstats
path: root/alembic
diff options
context:
space:
mode:
authorGravatar Joe Banks <[email protected]>2020-08-25 16:49:27 +0100
committerGravatar Joe Banks <[email protected]>2020-08-25 16:49:27 +0100
commit0dfed0a3681981a95fde4a5b8dde261d17b00010 (patch)
treea453942802b714f216e16bffb84dbd66301e272d /alembic
parentUse a foreign key for channel category (diff)
Major adjustments to data storage, strings instead of bigints for metabase compatibility
Diffstat (limited to 'alembic')
-rw-r--r--alembic/versions/2743389eb63e_add_all_tables_with_string_keys.py63
-rw-r--r--alembic/versions/2e383ecae493_remove_all_tables_for_conversion_to_.py27
2 files changed, 90 insertions, 0 deletions
diff --git a/alembic/versions/2743389eb63e_add_all_tables_with_string_keys.py b/alembic/versions/2743389eb63e_add_all_tables_with_string_keys.py
new file mode 100644
index 0000000..10bb0d2
--- /dev/null
+++ b/alembic/versions/2743389eb63e_add_all_tables_with_string_keys.py
@@ -0,0 +1,63 @@
+"""add all tables with string keys
+
+Revision ID: 2743389eb63e
+Revises: 2e383ecae493
+Create Date: 2020-08-25 16:35:38.833315
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '2743389eb63e'
+down_revision = '2e383ecae493'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.create_table('categories',
+ sa.Column('id', sa.String(), nullable=False),
+ sa.Column('name', sa.String(), nullable=False),
+ sa.PrimaryKeyConstraint('id')
+ )
+ op.create_table('users',
+ sa.Column('id', sa.String(), nullable=False),
+ sa.Column('name', sa.String(), nullable=False),
+ sa.Column('avatar_hash', sa.String(), nullable=True),
+ sa.Column('joined_at', sa.DateTime(), nullable=False),
+ sa.Column('created_at', sa.DateTime(), nullable=False),
+ sa.Column('is_staff', sa.Boolean(), nullable=False),
+ sa.Column('opt_out', sa.Boolean(), nullable=True),
+ sa.Column('bot', sa.Boolean(), nullable=True),
+ sa.PrimaryKeyConstraint('id')
+ )
+ op.create_table('channels',
+ sa.Column('id', sa.String(), nullable=False),
+ sa.Column('name', sa.String(), nullable=False),
+ sa.Column('category_id', sa.String(), nullable=True),
+ sa.Column('is_staff', sa.Boolean(), nullable=False),
+ sa.ForeignKeyConstraint(['category_id'], ['categories.id'], ),
+ sa.PrimaryKeyConstraint('id')
+ )
+ op.create_table('messages',
+ sa.Column('id', sa.String(), nullable=False),
+ sa.Column('channel_id', sa.String(), nullable=True),
+ sa.Column('author_id', sa.String(), nullable=True),
+ sa.Column('created_at', sa.DateTime(), nullable=True),
+ sa.ForeignKeyConstraint(['author_id'], ['users.id'], ondelete='CASCADE'),
+ sa.ForeignKeyConstraint(['channel_id'], ['channels.id'], ondelete='CASCADE'),
+ sa.PrimaryKeyConstraint('id')
+ )
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.drop_table('messages')
+ op.drop_table('channels')
+ op.drop_table('users')
+ op.drop_table('categories')
+ # ### end Alembic commands ###
diff --git a/alembic/versions/2e383ecae493_remove_all_tables_for_conversion_to_.py b/alembic/versions/2e383ecae493_remove_all_tables_for_conversion_to_.py
new file mode 100644
index 0000000..33f3673
--- /dev/null
+++ b/alembic/versions/2e383ecae493_remove_all_tables_for_conversion_to_.py
@@ -0,0 +1,27 @@
+"""remove all tables for conversion to string keys
+
+Revision ID: 2e383ecae493
+Revises: b1fdfe71fcb7
+Create Date: 2020-08-25 16:31:05.025135
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '2e383ecae493'
+down_revision = 'b1fdfe71fcb7'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ op.drop_table('messages')
+ op.drop_table('users')
+ op.drop_table('channels')
+ op.drop_table('categories')
+
+
+def downgrade():
+ pass