|
| 1 | +"""init |
| 2 | +
|
| 3 | +Revision ID: 180cc3782c77 |
| 4 | +Revises: |
| 5 | +Create Date: 2024-03-07 18:57:29.839982 |
| 6 | +
|
| 7 | +""" |
| 8 | +from typing import Sequence, Union |
| 9 | + |
| 10 | +from alembic import op |
| 11 | +import sqlalchemy as sa |
| 12 | + |
| 13 | + |
| 14 | +# revision identifiers, used by Alembic. |
| 15 | +revision: str = '180cc3782c77' |
| 16 | +down_revision: Union[str, None] = None |
| 17 | +branch_labels: Union[str, Sequence[str], None] = None |
| 18 | +depends_on: Union[str, Sequence[str], None] = None |
| 19 | + |
| 20 | + |
| 21 | +def upgrade() -> None: |
| 22 | + # ### commands auto generated by Alembic - please adjust! ### |
| 23 | + op.create_table('cities', |
| 24 | + sa.Column('id', sa.Integer(), nullable=False), |
| 25 | + sa.Column('name', sa.String(), nullable=True), |
| 26 | + sa.PrimaryKeyConstraint('id') |
| 27 | + ) |
| 28 | + op.create_table('tags', |
| 29 | + sa.Column('id', sa.Integer(), nullable=False), |
| 30 | + sa.Column('title', sa.String(), nullable=True), |
| 31 | + sa.Column('description', sa.String(), nullable=True), |
| 32 | + sa.PrimaryKeyConstraint('id') |
| 33 | + ) |
| 34 | + op.create_table('users', |
| 35 | + sa.Column('id', sa.Integer(), nullable=False), |
| 36 | + sa.Column('username', sa.String(), nullable=True), |
| 37 | + sa.Column('email', sa.String(), nullable=True), |
| 38 | + sa.Column('full_name', sa.String(), nullable=True), |
| 39 | + sa.Column('password', sa.String(), nullable=True), |
| 40 | + sa.PrimaryKeyConstraint('id') |
| 41 | + ) |
| 42 | + op.create_table('songs', |
| 43 | + sa.Column('id', sa.Integer(), nullable=False), |
| 44 | + sa.Column('name', sa.String(), nullable=True), |
| 45 | + sa.Column('artist', sa.String(), nullable=True), |
| 46 | + sa.Column('description', sa.String(), nullable=True), |
| 47 | + sa.Column('year', sa.Integer(), nullable=True), |
| 48 | + sa.Column('city_id', sa.Integer(), nullable=True), |
| 49 | + sa.ForeignKeyConstraint(['city_id'], ['cities.id'], ), |
| 50 | + sa.PrimaryKeyConstraint('id') |
| 51 | + ) |
| 52 | + op.create_table('song_tag', |
| 53 | + sa.Column('song_id', sa.Integer(), nullable=False), |
| 54 | + sa.Column('tag_id', sa.Integer(), nullable=False), |
| 55 | + sa.ForeignKeyConstraint(['song_id'], ['songs.id'], ), |
| 56 | + sa.ForeignKeyConstraint(['tag_id'], ['tags.id'], ), |
| 57 | + sa.PrimaryKeyConstraint('song_id', 'tag_id') |
| 58 | + ) |
| 59 | + # ### end Alembic commands ### |
| 60 | + |
| 61 | + |
| 62 | +def downgrade() -> None: |
| 63 | + # ### commands auto generated by Alembic - please adjust! ### |
| 64 | + op.drop_table('song_tag') |
| 65 | + op.drop_table('songs') |
| 66 | + op.drop_table('users') |
| 67 | + op.drop_table('tags') |
| 68 | + op.drop_table('cities') |
| 69 | + # ### end Alembic commands ### |
0 commit comments