Skip to content

Commit

Permalink
Add initial migration
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyMcCormick committed May 13, 2024
1 parent e28a917 commit 868c393
Showing 1 changed file with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
"""Initial migration
Revision ID: cac6140fdbf9
Revises:
Create Date: 2024-05-13 16:18:47.291448
Revision ID: f1540475192e
Revises:
Create Date: 2024-05-13 17:48:42.947299
"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
from sqlalchemy.dialects import oracle
from alembic import op
from sqlalchemy.dialects import mysql, oracle

# revision identifiers, used by Alembic.
revision: str = 'cac6140fdbf9'
revision: str = 'f1540475192e'
down_revision: Union[str, None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.execute("CREATE SCHEMA IF NOT EXISTS cdb_latiss")
op.execute('CREATE SCHEMA IF NOT EXISTS cdb_latiss')
op.create_table('exposure',
sa.Column('exposure_id', sa.BIGINT().with_variant(mysql.BIGINT(), 'mysql').with_variant(oracle.NUMBER(precision=38, scale=0, asdecimal=False), 'oracle').with_variant(sa.BIGINT(), 'postgresql'), nullable=False, comment='Unique identifier.'),
sa.Column('exposure_name', sa.VARCHAR(length=20).with_variant(mysql.VARCHAR(length=20), 'mysql').with_variant(oracle.VARCHAR2(length=20), 'oracle').with_variant(sa.VARCHAR(length=20), 'postgresql'), nullable=False, comment='Official name of the exposure.'),
Expand Down Expand Up @@ -80,15 +79,15 @@ def upgrade() -> None:
schema='cdb_latiss'
)
op.create_table('exposure_flexdata_schema',
sa.Column('key', sa.TEXT().with_variant(mysql.LONGTEXT(), 'mysql').with_variant(sa.CLOB(), 'oracle').with_variant(sa.TEXT(), 'postgresql'), nullable=True, comment='Name of key.'),
sa.Column('key', sa.TEXT().with_variant(mysql.LONGTEXT(), 'mysql').with_variant(sa.CLOB(), 'oracle').with_variant(sa.TEXT(), 'postgresql'), nullable=False, comment='Name of key.'),
sa.Column('dtype', sa.TEXT().with_variant(mysql.LONGTEXT(), 'mysql').with_variant(sa.CLOB(), 'oracle').with_variant(sa.TEXT(), 'postgresql'), nullable=True, comment='Name of the data type of the value, one of bool, int, float, str.'),
sa.Column('doc', sa.TEXT().with_variant(mysql.LONGTEXT(), 'mysql').with_variant(sa.CLOB(), 'oracle').with_variant(sa.TEXT(), 'postgresql'), nullable=True, comment='Documentation string. Can include units and IVOA UCD.'),
sa.PrimaryKeyConstraint('key'),
schema='cdb_latiss'
)
op.create_table('exposure_flexdata',
sa.Column('obs_id', sa.BIGINT().with_variant(mysql.BIGINT(), 'mysql').with_variant(oracle.NUMBER(precision=38, scale=0, asdecimal=False), 'oracle').with_variant(sa.BIGINT(), 'postgresql'), nullable=True, comment='Unique identifier.'),
sa.Column('key', sa.TEXT().with_variant(mysql.LONGTEXT(), 'mysql').with_variant(sa.CLOB(), 'oracle').with_variant(sa.TEXT(), 'postgresql'), nullable=True, comment='Name of key.'),
sa.Column('obs_id', sa.BIGINT().with_variant(mysql.BIGINT(), 'mysql').with_variant(oracle.NUMBER(precision=38, scale=0, asdecimal=False), 'oracle').with_variant(sa.BIGINT(), 'postgresql'), nullable=False, comment='Unique identifier.'),
sa.Column('key', sa.TEXT().with_variant(mysql.LONGTEXT(), 'mysql').with_variant(sa.CLOB(), 'oracle').with_variant(sa.TEXT(), 'postgresql'), nullable=False, comment='Name of key.'),
sa.Column('value', sa.TEXT().with_variant(mysql.LONGTEXT(), 'mysql').with_variant(sa.CLOB(), 'oracle').with_variant(sa.TEXT(), 'postgresql'), nullable=True, comment='Content of value as a string.'),
sa.ForeignKeyConstraint(['key'], ['cdb_latiss.exposure_flexdata_schema.key'], name='fk_key'),
sa.ForeignKeyConstraint(['obs_id'], ['cdb_latiss.exposure.exposure_id'], name='fk_obs_id'),
Expand Down

0 comments on commit 868c393

Please sign in to comment.