-
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 #104 from Subaru-PFS/tickets/OBSPROC-110
Tickets/obsproc 110
- Loading branch information
Showing
16 changed files
with
215 additions
and
40 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
...1-gb/alembic/versions/20241220-145409_0b72e62efd44_add_partner_column_in_the_proposal_.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,41 @@ | ||
"""add partner column in the proposal table and partner table | ||
Revision ID: 0b72e62efd44 | ||
Revises: b68482e38606 | ||
Create Date: 2024-12-20 14:54:09.851011 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = '0b72e62efd44' | ||
down_revision = 'b68482e38606' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table('partner', | ||
sa.Column('partner_id', sa.Integer(), autoincrement=False, nullable=False, comment='Unique identifier of the partner'), | ||
sa.Column('partner_name', sa.String(), nullable=False, comment='Name of the partner (e.g., subaru, gemini, keck, and uh)'), | ||
sa.Column('partner_description', sa.String(), nullable=True, comment='Description of the partner'), | ||
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.PrimaryKeyConstraint('partner_id'), | ||
sa.UniqueConstraint('partner_id'), | ||
sa.UniqueConstraint('partner_name') | ||
) | ||
op.add_column('proposal', sa.Column('partner_id', sa.Integer(), nullable=True)) | ||
op.create_foreign_key(None, 'proposal', 'partner', ['partner_id'], ['partner_id']) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_constraint(None, 'proposal', type_='foreignkey') | ||
op.drop_column('proposal', 'partner_id') | ||
op.drop_table('partner') | ||
# ### 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# `partner` | ||
|
||
## Overview | ||
|
||
The `partner` table is used to store the information on partner institutions. | ||
|
||
## Columns | ||
|
||
Here are the columns in the `partner` table: | ||
|
||
| Column Name | Type | Description | Required[^1] | Default | | ||
| ------------------- | -------- | ---------------------------------------------------------- | ------------ | ------- | | ||
| partner_id | int | The unique identifier of the partner | \* | | | ||
| partner_name | str | The name of the partner | \* | | | ||
| partner_description | str | A brief description of the partner | | "" | | ||
| 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 | ||
|
||
- `partner_id` is the primary key of the table and must be unique. However, it not set as an auto-increment column. | ||
|
||
## Available proposal categories | ||
|
||
| partner_id | partner_name | partner_description | | ||
| ---------: | ------------ | ---------------------- | | ||
| 1 | subaru | Subaru Telescope | | ||
| 2 | keck | W. M. Keck Observatory | | ||
| 3 | gemini | Gemini Observatory | | ||
| 4 | uh | University of Hawaii | |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# public.partner | ||
|
||
## Description | ||
|
||
## Columns | ||
|
||
| Name | Type | Default | Nullable | Children | Parents | Comment | | ||
| ---- | ---- | ------- | -------- | -------- | ------- | ------- | | ||
| partner_id | integer | | false | | | Unique identifier of the partner | | ||
| partner_name | varchar | | false | | | Name of the partner (e.g., subaru, gemini, keck, and uh) | | ||
| partner_description | varchar | | true | | | Description of the partner | | ||
| created_at | timestamp without time zone | timezone('utc'::text, CURRENT_TIMESTAMP) | true | | | The date and time in UTC when the record was created | | ||
| updated_at | timestamp without time zone | | true | | | The date and time in UTC when the record was last updated | | ||
|
||
## Constraints | ||
|
||
| Name | Type | Definition | | ||
| ---- | ---- | ---------- | | ||
| partner_pkey | PRIMARY KEY | PRIMARY KEY (partner_id) | | ||
| partner_partner_name_key | UNIQUE | UNIQUE (partner_name) | | ||
|
||
## Indexes | ||
|
||
| Name | Definition | | ||
| ---- | ---------- | | ||
| partner_pkey | CREATE UNIQUE INDEX partner_pkey ON public.partner USING btree (partner_id) | | ||
| partner_partner_name_key | CREATE UNIQUE INDEX partner_partner_name_key ON public.partner USING btree (partner_name) | | ||
|
||
## Relations | ||
|
||
```mermaid | ||
erDiagram | ||
"public.partner" { | ||
integer partner_id | ||
varchar partner_name | ||
varchar partner_description | ||
timestamp_without_time_zone created_at | ||
timestamp_without_time_zone updated_at | ||
} | ||
``` | ||
|
||
--- | ||
|
||
> Generated by [tbls](https://github.com/k1LoW/tbls) |
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,5 @@ | ||
partner_id,partner_name,partner_description | ||
1,subaru,Subaru Telescope | ||
2,keck,"W. M. Keck Observatory" | ||
3,gemini,Gemini Telescope | ||
4,uh,University of Hawaii |
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 |
---|---|---|
@@ -1,5 +1,2 @@ | ||
proposal_category_id,proposal_category_name,proposal_category_description | ||
1,openuse,Subaru openuse proposal | ||
2,keck,Subaru/Keck time exchange proposal | ||
3,gemini,Subaru/Gemini time exchange proposal | ||
4,uh,University of Hawaii proposal |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env python | ||
|
||
from sqlalchemy import ( | ||
Column, | ||
DateTime, | ||
Integer, | ||
String, | ||
) | ||
from sqlalchemy.orm import relationship | ||
|
||
from . import Base, comment_created_at, comment_updated_at, utcnow | ||
|
||
|
||
class partner(Base): | ||
__tablename__ = "partner" | ||
|
||
partner_id = Column( | ||
Integer, | ||
primary_key=True, | ||
unique=True, | ||
autoincrement=False, | ||
comment="Unique identifier of the partner", | ||
) | ||
partner_name = Column( | ||
String, | ||
unique=True, | ||
nullable=False, | ||
comment="Name of the partner (e.g., subaru, gemini, keck, and uh)", | ||
) | ||
partner_description = Column( | ||
String, default="", comment="Description of the partner" | ||
) | ||
created_at = Column( | ||
DateTime, | ||
comment=comment_created_at, | ||
server_default=utcnow(), | ||
) | ||
updated_at = Column( | ||
DateTime, | ||
comment=comment_updated_at, | ||
onupdate=utcnow(), | ||
) | ||
|
||
proposals = relationship("proposal", backref="partner") |
Oops, something went wrong.