Skip to content

Commit

Permalink
Merge pull request #1100 from debrief/extend-field-lengths
Browse files Browse the repository at this point in the history
Extend length of two fields in database
  • Loading branch information
IanMayo authored Dec 6, 2021
2 parents 7ed865f + a538092 commit 021a897
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 6 deletions.
4 changes: 2 additions & 2 deletions migrations/latest_revisions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"LATEST_SQLITE_VERSION": "cebecb0b77a1",
"LATEST_POSTGRES_VERSION": "2bc85b76a38b"
"LATEST_SQLITE_VERSION": "fddfa70f811b",
"LATEST_POSTGRES_VERSION": "a5a4bc1f7156"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""Extend length of Platform.identifier field
Revision ID: 39b90ad3675e
Revises: 2bc85b76a38b
Create Date: 2021-12-01 21:08:52.761161+00:00
"""
import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "39b90ad3675e"
down_revision = "2bc85b76a38b"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column(
"Platforms",
"identifier",
existing_type=sa.VARCHAR(length=30),
type_=sa.String(length=50),
existing_nullable=False,
schema="pepys",
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column(
"Platforms",
"identifier",
existing_type=sa.String(length=50),
type_=sa.VARCHAR(length=30),
existing_nullable=False,
schema="pepys",
)
# ### end Alembic commands ###
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""Extend length of Contact.track_number field
Revision ID: a5a4bc1f7156
Revises: 39b90ad3675e
Create Date: 2021-12-03 16:48:18.324573+00:00
"""
import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "a5a4bc1f7156"
down_revision = "39b90ad3675e"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column(
"Contacts",
"track_number",
existing_type=sa.VARCHAR(length=20),
type_=sa.String(length=40),
existing_nullable=True,
schema="pepys",
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column(
"Contacts",
"track_number",
existing_type=sa.String(length=40),
type_=sa.VARCHAR(length=20),
existing_nullable=True,
schema="pepys",
)
# ### end Alembic commands ###
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""Extend length of Platform.identifier field
Revision ID: eb8a93498c02
Revises: cebecb0b77a1
Create Date: 2021-12-01 21:10:36.015159+00:00
"""
import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "eb8a93498c02"
down_revision = "cebecb0b77a1"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("Platforms", schema=None) as batch_op:
batch_op.alter_column(
"identifier",
existing_type=sa.VARCHAR(length=30),
type_=sa.String(length=50),
existing_nullable=False,
)

# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("Platforms", schema=None) as batch_op:
batch_op.alter_column(
"identifier",
existing_type=sa.String(length=50),
type_=sa.VARCHAR(length=30),
existing_nullable=False,
)
# ### end Alembic commands ###
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""Extend length of Contact.track_number field
Revision ID: fddfa70f811b
Revises: eb8a93498c02
Create Date: 2021-12-03 16:49:33.809704+00:00
"""
import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "fddfa70f811b"
down_revision = "eb8a93498c02"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("Contacts", schema=None) as batch_op:
batch_op.alter_column(
"track_number",
existing_type=sa.VARCHAR(length=20),
type_=sa.String(length=40),
existing_nullable=True,
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("Contacts", schema=None) as batch_op:
batch_op.alter_column(
"track_number",
existing_type=sa.String(length=40),
type_=sa.VARCHAR(length=20),
existing_nullable=True,
)

# ### end Alembic commands ###
4 changes: 2 additions & 2 deletions pepys_import/core/store/postgres_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class Platform(BasePostGIS, PlatformMixin):
String(150), CheckConstraint("name <> ''", name="ck_Platforms_name"), nullable=False
)
identifier = Column(
String(30),
String(50),
CheckConstraint("identifier <> ''", name="ck_Platforms_identifier"),
nullable=False,
)
Expand Down Expand Up @@ -766,7 +766,7 @@ class Contact(BasePostGIS, ContactMixin, LocationPropertyMixin, ElevationPropert
)
_mla = deferred(Column("mla", DOUBLE_PRECISION))
_soa = deferred(Column("soa", DOUBLE_PRECISION))
track_number = Column(String(20))
track_number = Column(String(40))
subject_id = Column(
UUID(as_uuid=True),
ForeignKey("pepys.Platforms.platform_id", onupdate="cascade", ondelete="cascade"),
Expand Down
4 changes: 2 additions & 2 deletions pepys_import/core/store/sqlite_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class Platform(BaseSpatiaLite, PlatformMixin):
String(150), CheckConstraint("name <> ''", name="ck_Platforms_name"), nullable=False
)
identifier = Column(
String(30),
String(50),
CheckConstraint("identifier <> ''", name="ck_Platforms_identifier"),
nullable=False,
)
Expand Down Expand Up @@ -772,7 +772,7 @@ class Contact(BaseSpatiaLite, ContactMixin, LocationPropertyMixin, ElevationProp
contact_type = deferred(Column(UUIDType, ForeignKey("ContactTypes.contact_type_id")))
_mla = deferred(Column("mla", REAL))
_soa = deferred(Column("soa", REAL))
track_number = Column(String(20))
track_number = Column(String(40))
subject_id = Column(
UUIDType, ForeignKey("Platforms.platform_id", onupdate="cascade", ondelete="cascade")
)
Expand Down

0 comments on commit 021a897

Please sign in to comment.