-
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 #19 from GispoCoding/add-source-data
Add source data
- Loading branch information
Showing
4 changed files
with
126 additions
and
1 deletion.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
database/migrations/versions/2024_02_15_0955-194b9836f0a0_add_source_data_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,67 @@ | ||
"""add_source_data_table | ||
Revision ID: 194b9836f0a0 | ||
Revises: 7de05df06dce | ||
Create Date: 2024-02-15 09:55:59.456659 | ||
""" | ||
from typing import Sequence, Union | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# import geoalchemy2 | ||
from sqlalchemy.dialects import postgresql | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "194b9836f0a0" | ||
down_revision: Union[str, None] = "7de05df06dce" | ||
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( | ||
"source_data", | ||
sa.Column("type_of_source_data_id", sa.UUID(), nullable=False), | ||
sa.Column( | ||
"name", | ||
postgresql.JSONB(astext_type=sa.Text()), | ||
server_default='{"fin": "", "swe": "", "eng": ""}', | ||
nullable=False, | ||
), | ||
sa.Column( | ||
"language", | ||
postgresql.JSONB(astext_type=sa.Text()), | ||
server_default='{"fin": "", "swe": "", "eng": ""}', | ||
nullable=False, | ||
), | ||
sa.Column("additional_information_uri", sa.String(), nullable=False), | ||
sa.Column( | ||
"id", sa.UUID(), server_default=sa.text("gen_random_uuid()"), nullable=False | ||
), | ||
sa.Column( | ||
"created_at", sa.DateTime(), server_default=sa.text("now()"), nullable=False | ||
), | ||
sa.Column( | ||
"modified_at", | ||
sa.DateTime(), | ||
server_default=sa.text("now()"), | ||
nullable=False, | ||
), | ||
sa.ForeignKeyConstraint( | ||
["type_of_source_data_id"], | ||
["codes.type_of_source_data.id"], | ||
name="type_of_source_data_id_fkey", | ||
), | ||
sa.PrimaryKeyConstraint("id"), | ||
schema="hame", | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_table("source_data", schema="hame") | ||
# ### end Alembic commands ### |
42 changes: 42 additions & 0 deletions
42
...grations/versions/2024_02_22_1145-f90c256163dd_remove_language_field_from_source_data_.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,42 @@ | ||
"""remove_language_field_from_source_data_table | ||
Revision ID: f90c256163dd | ||
Revises: 194b9836f0a0 | ||
Create Date: 2024-02-22 11:45:58.388376 | ||
""" | ||
from typing import Sequence, Union | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# import geoalchemy2 | ||
from sqlalchemy.dialects import postgresql | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "f90c256163dd" | ||
down_revision: Union[str, None] = "194b9836f0a0" | ||
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.drop_column("source_data", "language", schema="hame") | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.add_column( | ||
"source_data", | ||
sa.Column( | ||
"language", | ||
postgresql.JSONB(astext_type=sa.Text()), | ||
server_default=sa.text('\'{"eng": "", "fin": "", "swe": ""}\'::jsonb'), | ||
autoincrement=False, | ||
nullable=False, | ||
), | ||
schema="hame", | ||
) | ||
# ### end Alembic commands ### |
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