Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-999999999: Migrate schema changes (Example only) - DO NOT MERGE #60

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
212 changes: 212 additions & 0 deletions alembic/latiss/versions/d0cf7fec0365_dm_999999999.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
"""DM-999999999

Revision ID: d0cf7fec0365
Revises: e9fd2cdb9c12
Create Date: 2024-11-26 18:22:08.509793+00:00

"""

from typing import Sequence, Union

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

# revision identifiers, used by Alembic.
revision: str = "d0cf7fec0365"
down_revision: Union[str, None] = "e9fd2cdb9c12"
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.create_table(
"exposure_quicklook",
sa.Column(
"exposure_id",
sa.BIGINT().with_variant(mysql.BIGINT(), "mysql").with_variant(sa.BIGINT(), "postgresql"),
nullable=False,
comment="Unique identifier.",
),
sa.Column(
"day_obs",
sa.INTEGER().with_variant(mysql.INTEGER(), "mysql").with_variant(sa.INTEGER(), "postgresql"),
nullable=False,
comment="Day of observation.",
),
sa.Column(
"seq_num",
sa.INTEGER().with_variant(mysql.INTEGER(), "mysql").with_variant(sa.INTEGER(), "postgresql"),
nullable=False,
comment="Sequence number.",
),
sa.Column(
"postisr_pixel_median",
sa.FLOAT().with_variant(mysql.FLOAT(), "mysql").with_variant(sa.FLOAT(), "postgresql"),
nullable=True,
comment="Median postISR pixel value.",
),
sa.Column(
"mount_motion_image_degradation",
sa.FLOAT().with_variant(mysql.FLOAT(), "mysql").with_variant(sa.FLOAT(), "postgresql"),
nullable=True,
comment="Image degradation due to mount motion.",
),
sa.Column(
"mount_motion_image_degradation_az",
sa.FLOAT().with_variant(mysql.FLOAT(), "mysql").with_variant(sa.FLOAT(), "postgresql"),
nullable=True,
comment="Image degradation due to mount motion in azimuth.",
),
sa.Column(
"mount_motion_image_degradation_el",
sa.FLOAT().with_variant(mysql.FLOAT(), "mysql").with_variant(sa.FLOAT(), "postgresql"),
nullable=True,
comment="Image degradation due to mount motion in elevation.",
),
sa.Column(
"mount_jitter_rms",
sa.FLOAT().with_variant(mysql.FLOAT(), "mysql").with_variant(sa.FLOAT(), "postgresql"),
nullable=True,
comment="RMS mount jitter.",
),
sa.Column(
"mount_jitter_rms_az",
sa.FLOAT().with_variant(mysql.FLOAT(), "mysql").with_variant(sa.FLOAT(), "postgresql"),
nullable=True,
comment="Azimuth RMS mount jitter.",
),
sa.Column(
"mount_jitter_rms_el",
sa.FLOAT().with_variant(mysql.FLOAT(), "mysql").with_variant(sa.FLOAT(), "postgresql"),
nullable=True,
comment="Elevation RMS mount jitter.",
),
sa.Column(
"mount_jitter_rms_rot",
sa.FLOAT().with_variant(mysql.FLOAT(), "mysql").with_variant(sa.FLOAT(), "postgresql"),
nullable=True,
comment="Rotator RMS mount jitter.",
),
sa.ForeignKeyConstraint(
["day_obs", "seq_num"],
["cdb_latiss.exposure.day_obs", "cdb_latiss.exposure.seq_num"],
name="fk_exposure_quicklook_day_obs_seq_num",
),
sa.ForeignKeyConstraint(
["exposure_id"], ["cdb_latiss.exposure.exposure_id"], name="fk_exposure_quicklook_obs_id"
),
sa.PrimaryKeyConstraint("day_obs", "seq_num"),
schema="cdb_latiss",
mysql_engine="MyISAM",
)
op.add_column(
"ccdvisit1_quicklook",
sa.Column(
"pixel_scale",
sa.FLOAT().with_variant(mysql.FLOAT(), "mysql").with_variant(sa.FLOAT(), "postgresql"),
nullable=True,
comment="Measured detector pixel scale.",
),
schema="cdb_latiss",
)
op.add_column(
"ccdvisit1_quicklook",
sa.Column(
"psf_ap_flux_delta",
sa.FLOAT().with_variant(mysql.FLOAT(), "mysql").with_variant(sa.FLOAT(), "postgresql"),
nullable=True,
comment="Delta (max - min) of model psf aperture flux (with aperture radius of max(2, 3*psfSigma)) values evaluated on a grid of unmasked pixels.",
),
schema="cdb_latiss",
)
op.add_column(
"ccdvisit1_quicklook",
sa.Column(
"psf_ap_corr_sigma_scaled_delta",
sa.FLOAT().with_variant(mysql.FLOAT(), "mysql").with_variant(sa.FLOAT(), "postgresql"),
nullable=True,
comment="Delta (max - min) of psf flux aperture correction factors scaled (divided) by the psfSigma evaluated on a grid of unmasked pixels.",
),
schema="cdb_latiss",
)
op.add_column(
"ccdvisit1_quicklook",
sa.Column(
"dummy_column26",
sa.VARCHAR(length=64)
.with_variant(mysql.VARCHAR(length=64), "mysql")
.with_variant(sa.VARCHAR(length=64), "postgresql"),
nullable=True,
comment="Dummy column for testing.",
),
schema="cdb_latiss",
)
op.add_column(
"visit1_quicklook",
sa.Column(
"pixel_scale",
sa.FLOAT().with_variant(mysql.FLOAT(), "mysql").with_variant(sa.FLOAT(), "postgresql"),
nullable=True,
comment="Measured detector pixel scale.",
),
schema="cdb_latiss",
)
op.add_column(
"visit1_quicklook",
sa.Column(
"stats_mag_lim",
sa.FLOAT().with_variant(mysql.FLOAT(), "mysql").with_variant(sa.FLOAT(), "postgresql"),
nullable=True,
comment="Magnitude limit at fixed SNR (default SNR=5) calculated from exposure summary stats.",
),
schema="cdb_latiss",
)
op.add_column(
"visit1_quicklook",
sa.Column(
"psf_ap_flux_delta",
sa.FLOAT().with_variant(mysql.FLOAT(), "mysql").with_variant(sa.FLOAT(), "postgresql"),
nullable=True,
comment="Delta (max - min) of model psf aperture flux (with aperture radius of max(2, 3*psfSigma)) values evaluated on a grid of unmasked pixels.",
),
schema="cdb_latiss",
)
op.add_column(
"visit1_quicklook",
sa.Column(
"psf_ap_corr_sigma_scaled_delta",
sa.FLOAT().with_variant(mysql.FLOAT(), "mysql").with_variant(sa.FLOAT(), "postgresql"),
nullable=True,
comment="Delta (max - min) of psf flux aperture correction factors scaled (divided) by the psfSigma evaluated on a grid of unmasked pixels.",
),
schema="cdb_latiss",
)
op.drop_column("visit1_quicklook", "postisr_pixel_median", schema="cdb_latiss")
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
"visit1_quicklook",
sa.Column(
"postisr_pixel_median",
sa.DOUBLE_PRECISION(precision=53),
autoincrement=False,
nullable=True,
comment="Median postISR pixel value.",
),
schema="cdb_latiss",
)
op.drop_column("visit1_quicklook", "psf_ap_corr_sigma_scaled_delta", schema="cdb_latiss")
op.drop_column("visit1_quicklook", "psf_ap_flux_delta", schema="cdb_latiss")
op.drop_column("visit1_quicklook", "stats_mag_lim", schema="cdb_latiss")
op.drop_column("visit1_quicklook", "pixel_scale", schema="cdb_latiss")
op.drop_column("ccdvisit1_quicklook", "dummy_column26", schema="cdb_latiss")
op.drop_column("ccdvisit1_quicklook", "psf_ap_corr_sigma_scaled_delta", schema="cdb_latiss")
op.drop_column("ccdvisit1_quicklook", "psf_ap_flux_delta", schema="cdb_latiss")
op.drop_column("ccdvisit1_quicklook", "pixel_scale", schema="cdb_latiss")
op.drop_table("exposure_quicklook", schema="cdb_latiss")
# ### end Alembic commands ###
Loading