|
| 1 | +"""init migrations |
| 2 | +
|
| 3 | +Revision ID: 0d1ee3949d21 |
| 4 | +Revises: |
| 5 | +Create Date: 2023-03-11 20:08:07.362613 |
| 6 | +
|
| 7 | +""" |
| 8 | +from alembic import op |
| 9 | +import sqlalchemy as sa |
| 10 | +from sqlalchemy.dialects import postgresql |
| 11 | + |
| 12 | +# revision identifiers, used by Alembic. |
| 13 | +revision = '0d1ee3949d21' |
| 14 | +down_revision = None |
| 15 | +branch_labels = None |
| 16 | +depends_on = None |
| 17 | + |
| 18 | + |
| 19 | +def upgrade(): |
| 20 | + # ### commands auto generated by Alembic - please adjust! ### |
| 21 | + op.create_table('nonsense', |
| 22 | + sa.Column('id', sa.UUID(), autoincrement=True, nullable=True), |
| 23 | + sa.Column('name', sa.String(), nullable=False), |
| 24 | + sa.Column('description', sa.String(), nullable=False), |
| 25 | + sa.PrimaryKeyConstraint('name'), |
| 26 | + sa.UniqueConstraint('id'), |
| 27 | + sa.UniqueConstraint('name'), |
| 28 | + schema='happy_hog' |
| 29 | + ) |
| 30 | + op.create_table('stuff', |
| 31 | + sa.Column('id', sa.UUID(), autoincrement=True, nullable=True), |
| 32 | + sa.Column('name', sa.String(), nullable=False), |
| 33 | + sa.Column('description', sa.String(), nullable=False), |
| 34 | + sa.PrimaryKeyConstraint('name'), |
| 35 | + sa.UniqueConstraint('id'), |
| 36 | + sa.UniqueConstraint('name'), |
| 37 | + schema='happy_hog' |
| 38 | + ) |
| 39 | + op.create_table('character', |
| 40 | + sa.Column('id', sa.String(length=32), nullable=False), |
| 41 | + sa.Column('name', sa.String(length=64), nullable=False), |
| 42 | + sa.Column('speech_count', sa.Integer(), nullable=False), |
| 43 | + sa.Column('abbrev', sa.String(length=32), nullable=True), |
| 44 | + sa.Column('description', sa.String(length=2056), nullable=True), |
| 45 | + sa.PrimaryKeyConstraint('id', name='character_pkey'), |
| 46 | + schema='shakespeare' |
| 47 | + ) |
| 48 | + op.create_table('wordform', |
| 49 | + sa.Column('id', sa.Integer(), nullable=False), |
| 50 | + sa.Column('plain_text', sa.String(length=64), nullable=False), |
| 51 | + sa.Column('phonetic_text', sa.String(length=64), nullable=False), |
| 52 | + sa.Column('stem_text', sa.String(length=64), nullable=False), |
| 53 | + sa.Column('occurences', sa.Integer(), nullable=False), |
| 54 | + sa.PrimaryKeyConstraint('id', name='wordform_pkey'), |
| 55 | + schema='shakespeare' |
| 56 | + ) |
| 57 | + op.create_table('work', |
| 58 | + sa.Column('id', sa.String(length=32), nullable=False), |
| 59 | + sa.Column('title', sa.String(length=32), nullable=False), |
| 60 | + sa.Column('long_title', sa.String(length=64), nullable=False), |
| 61 | + sa.Column('year', sa.Integer(), nullable=False), |
| 62 | + sa.Column('genre_type', sa.String(length=1), nullable=False), |
| 63 | + sa.Column('source', sa.String(length=16), nullable=False), |
| 64 | + sa.Column('total_words', sa.Integer(), nullable=False), |
| 65 | + sa.Column('total_paragraphs', sa.Integer(), nullable=False), |
| 66 | + sa.Column('notes', sa.Text(), nullable=True), |
| 67 | + sa.PrimaryKeyConstraint('id', name='work_pkey'), |
| 68 | + schema='shakespeare' |
| 69 | + ) |
| 70 | + op.create_table('chapter', |
| 71 | + sa.Column('id', sa.Integer(), nullable=False), |
| 72 | + sa.Column('work_id', sa.String(length=32), nullable=False), |
| 73 | + sa.Column('section_number', sa.Integer(), nullable=False), |
| 74 | + sa.Column('chapter_number', sa.Integer(), nullable=False), |
| 75 | + sa.Column('description', sa.String(length=256), nullable=False), |
| 76 | + sa.ForeignKeyConstraint(['work_id'], ['shakespeare.work.id'], name='chapter_work_id_fkey'), |
| 77 | + sa.PrimaryKeyConstraint('id', name='chapter_pkey'), |
| 78 | + sa.UniqueConstraint('work_id', 'section_number', 'chapter_number', name='chapter_work_id_section_number_chapter_number_key'), |
| 79 | + schema='shakespeare' |
| 80 | + ) |
| 81 | + op.create_table('character_work', |
| 82 | + sa.Column('character_id', sa.String(length=32), nullable=False), |
| 83 | + sa.Column('work_id', sa.String(length=32), nullable=False), |
| 84 | + sa.ForeignKeyConstraint(['character_id'], ['shakespeare.character.id'], name='character_work_character_id_fkey'), |
| 85 | + sa.ForeignKeyConstraint(['work_id'], ['shakespeare.work.id'], name='character_work_work_id_fkey'), |
| 86 | + sa.PrimaryKeyConstraint('character_id', 'work_id', name='character_work_pkey'), |
| 87 | + schema='shakespeare' |
| 88 | + ) |
| 89 | + op.create_table('paragraph', |
| 90 | + sa.Column('id', sa.Integer(), nullable=False), |
| 91 | + sa.Column('work_id', sa.String(length=32), nullable=False), |
| 92 | + sa.Column('paragraph_num', sa.Integer(), nullable=False), |
| 93 | + sa.Column('character_id', sa.String(length=32), nullable=False), |
| 94 | + sa.Column('plain_text', sa.Text(), nullable=False), |
| 95 | + sa.Column('phonetic_text', sa.Text(), nullable=False), |
| 96 | + sa.Column('stem_text', sa.Text(), nullable=False), |
| 97 | + sa.Column('paragraph_type', sa.String(length=1), nullable=False), |
| 98 | + sa.Column('section_number', sa.Integer(), nullable=False), |
| 99 | + sa.Column('chapter_number', sa.Integer(), nullable=False), |
| 100 | + sa.Column('char_count', sa.Integer(), nullable=False), |
| 101 | + sa.Column('word_count', sa.Integer(), nullable=False), |
| 102 | + sa.ForeignKeyConstraint(['character_id'], ['shakespeare.character.id'], name='paragraph_character_id_fkey'), |
| 103 | + sa.ForeignKeyConstraint(['work_id', 'section_number', 'chapter_number'], ['shakespeare.chapter.work_id', 'shakespeare.chapter.section_number', 'shakespeare.chapter.chapter_number'], name='paragraph_chapter_fkey'), |
| 104 | + sa.ForeignKeyConstraint(['work_id'], ['shakespeare.work.id'], name='paragraph_work_id_fkey'), |
| 105 | + sa.PrimaryKeyConstraint('id', name='paragraph_pkey'), |
| 106 | + schema='shakespeare' |
| 107 | + ) |
| 108 | + # ### end Alembic commands ### |
| 109 | + |
| 110 | + |
| 111 | +def downgrade(): |
| 112 | + # ### commands auto generated by Alembic - please adjust! ### |
| 113 | + op.drop_table('paragraph', schema='shakespeare') |
| 114 | + op.drop_table('character_work', schema='shakespeare') |
| 115 | + op.drop_table('chapter', schema='shakespeare') |
| 116 | + op.drop_table('work', schema='shakespeare') |
| 117 | + op.drop_table('wordform', schema='shakespeare') |
| 118 | + op.drop_table('character', schema='shakespeare') |
| 119 | + op.drop_table('stuff', schema='happy_hog') |
| 120 | + op.drop_table('nonsense', schema='happy_hog') |
| 121 | + # ### end Alembic commands ### |
0 commit comments