"""tokboard_top Revision ID: 6d146445ba28 Revises: 96d277eada7f Create Date: 2021-03-22 14:28:11.486556 """ # revision identifiers, used by Alembic. revision = '6d146445ba28' down_revision = '96d277eada7f' branch_labels = None depends_on = None from alembic import op import sqlalchemy as sa def upgrade(): op.execute(''' create table tokboard_top_songs ( sound_ttid text not null, as_of date not null, author_name text not null, title text not null, popular_video_count integer not null, video_count integer null, play_count bigint null, change integer null, created_at timestamp not null, updated_at timestamp not null, play_url text null, cover_url text null, is_original bool not null default false ) partition by range(as_of); create table tokboard_top_songs_default partition of tokboard_top_songs default; create unique index on tokboard_top_songs_default (as_of, sound_ttid); create table tokboard_top_songs_2103 partition of tokboard_top_songs FOR VALUES FROM ('2021-03-01') TO ('2021-04-01'); create unique index on tokboard_top_songs_2103 (as_of, sound_ttid); create table tokboard_top_songs_2104 partition of tokboard_top_songs FOR VALUES FROM ('2021-04-01') TO ('2021-05-01'); create unique index on tokboard_top_songs_2104 (as_of, sound_ttid); create table tokboard_top_songs_2105 partition of tokboard_top_songs FOR VALUES FROM ('2021-05-01') TO ('2021-06-01'); create unique index on tokboard_top_songs_2105 (as_of, sound_ttid); ''') def downgrade(): op.execute('''drop table tokboard_top_songs''')