-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #103 from Subaru-PFS/tickets/OBSPROC-101
Add `user_pointing` table to store custom pointing centers
- Loading branch information
Showing
19 changed files
with
472 additions
and
44 deletions.
There are no files selected for viewing
109 changes: 109 additions & 0 deletions
109
...bic/pfsa-db01-gb/alembic/versions/20241024-120338_b68482e38606_add_user_pointing_table.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
"""add user_pointing table | ||
Revision ID: b68482e38606 | ||
Revises: f07c300ae87f | ||
Create Date: 2024-10-24 12:03:38.150098 | ||
""" | ||
|
||
import sqlalchemy as sa | ||
|
||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "b68482e38606" | ||
down_revision = "f07c300ae87f" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table( | ||
"user_pointing", | ||
sa.Column( | ||
"user_pointing_id", | ||
sa.BigInteger(), | ||
nullable=False, | ||
comment="Unique identifier for each user-defined pointing (autoincremented primary key)", | ||
), | ||
sa.Column( | ||
"ppc_code", | ||
sa.String(), | ||
nullable=False, | ||
comment="String identifier of the pointing set either by the uploader or user", | ||
), | ||
sa.Column( | ||
"ppc_ra", | ||
sa.Float(), | ||
nullable=False, | ||
comment="RA of the pointing center (ICRS, degree)", | ||
), | ||
sa.Column( | ||
"ppc_dec", | ||
sa.Float(), | ||
nullable=False, | ||
comment="Dec of the pointing center (ICRS, degree)", | ||
), | ||
sa.Column( | ||
"ppc_pa", | ||
sa.Float(), | ||
nullable=False, | ||
comment="Position angle of the pointing center (degree)", | ||
), | ||
sa.Column( | ||
"ppc_resolution", | ||
sa.Enum("L", "M", name="resolutionmode"), | ||
nullable=False, | ||
comment="Resolution mode of the pointing ('L' or 'M')", | ||
), | ||
sa.Column( | ||
"ppc_priority", | ||
sa.Float(), | ||
nullable=False, | ||
comment="Priority of the pointing calculated by the uploader", | ||
), | ||
sa.Column( | ||
"input_catalog_id", | ||
sa.Integer(), | ||
nullable=False, | ||
comment="Input catalog ID from the input_catalog table", | ||
), | ||
sa.Column( | ||
"created_at", | ||
sa.DateTime(), | ||
server_default=sa.text("TIMEZONE('utc', CURRENT_TIMESTAMP)"), | ||
nullable=True, | ||
comment="The date and time in UTC when the record was created", | ||
), | ||
sa.Column( | ||
"updated_at", | ||
sa.DateTime(), | ||
nullable=True, | ||
comment="The date and time in UTC when the record was last updated", | ||
), | ||
sa.ForeignKeyConstraint( | ||
["input_catalog_id"], | ||
["input_catalog.input_catalog_id"], | ||
), | ||
sa.PrimaryKeyConstraint("user_pointing_id"), | ||
) | ||
op.add_column( | ||
"input_catalog", | ||
sa.Column( | ||
"is_user_pointing", | ||
sa.Boolean(), | ||
nullable=True, | ||
comment="True if user-defined pointings are provided", | ||
), | ||
) | ||
# op.drop_index('target_q3c_ang2ipix_idx1', table_name='target') | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
# op.create_index('target_q3c_ang2ipix_idx1', 'target', [sa.text('q3c_ang2ipix(ra, "dec")')], unique=False) | ||
op.drop_column("input_catalog", "is_user_pointing") | ||
op.drop_table("user_pointing") | ||
# ### end Alembic commands ### |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# `user_pointing` | ||
|
||
## Overview | ||
|
||
The `user_pointing` table is used to store the information on user-defined pointings. | ||
|
||
## Columns | ||
|
||
Here are the columns in the `user_pointing` table: | ||
|
||
| Column Name | Type | Description | Unit | Required[^1] | Default | | ||
| ---------------- | -------- | ---------------------------------------------------------- | ---- | ------------ | ------- | | ||
| user_pointing_id | int64 | The unique identifier of the record | | | | | ||
| ppc_code | str | Name of the pointing | | \* | | | ||
| ppc_ra | float | RA at the pointing center | deg | \* | | | ||
| ppc_dec | float | Dec at the pointing center | deg | \* | | | ||
| ppc_pa | float | Position angle of the pointing center | deg | \* | | | ||
| ppc_resolution | str | Resolution mode of the pointing (`L` or `M`) | | \* | | | ||
| ppc_priority | float | Sum of the priority weights of the pointing | | \* | | | ||
| input_catalog_id | int | `input_catalog_id` in the `input_catalog` table. | | | | | ||
| created_at | datetime | The date and time in UTC when the record was created. | | | | | ||
| updated_at | datetime | The date and time in UTC when the record was last updated. | | | | | ||
|
||
[^1]: Required when inserted by using the [CLI tool](../reference/cli.md) or equivalent functions. | ||
|
||
## Unique constraint | ||
|
||
- `user_pointing_id` is the primary key of the table and set as an auto-increment column. | ||
|
||
## Foreign key constraints | ||
|
||
- `input_catalog_id` is a foreign key constraint that references the `input_catalog_id` in the `input_catalog` table. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.