Skip to content
Open
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
2 changes: 2 additions & 0 deletions dynamicannotationdb/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def create_table(
with_crud_columns: bool = True,
read_permission: str = "PUBLIC",
write_permission: str = "PRIVATE",
keep_created_ts_col: bool = False,
notice_text: str = None,
):
r"""Create new annotation table unless already exists
Expand Down Expand Up @@ -144,6 +145,7 @@ def create_table(
"read_permission": read_permission,
"write_permission": write_permission,
"last_modified": creation_time,
"keep_created_ts_col": keep_created_ts_col,
"notice_text": notice_text,
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""Add keep created ts col

Revision ID: 4654f43b80f6
Revises: 309cf493a1e2
Create Date: 2023-01-17 17:16:11.658225

"""
from alembic import op
import sqlalchemy as sa

from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "4654f43b80f6"
down_revision = "309cf493a1e2"
branch_labels = None
depends_on = None


def upgrade():
op.add_column(
"annotation_table_metadata",
sa.Column("keep_created_ts_col", sa.Boolean(), nullable=True),
)

op.execute("UPDATE annotation_table_metadata SET keep_created_ts_col = False")
op.alter_column("annotation_table_metadata", "keep_created_ts_col", nullable=False)


def downgrade():
op.drop_column("annotation_table_metadata", "keep_created_ts_col")
7 changes: 5 additions & 2 deletions dynamicannotationdb/migration/migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,11 @@ def apply_cascade_option_to_tables(self, dry_run: bool = True):
raise error
return fkey_mappings

def add_cascade_delete_to_fkey(self, table: Table, dry_run: bool = True):
table_name = table.name
def add_cascade_delete_to_fkey(self, table: Table or str, dry_run: bool = True):
if isinstance(table, str):
table_name = table
else:
table_name = table.table
fkeys_to_drop = {}
fkey_to_add = {}
for fk in self.target_inspector.get_foreign_keys(table_name):
Expand Down
14 changes: 1 addition & 13 deletions dynamicannotationdb/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
from sqlalchemy.orm import relationship
from sqlalchemy.dialects import postgresql

# Models that will be created in the 'materialized' database.
MatBase = declarative_base()
# Models that will be created in the 'annotation' database.
AnnotationBase = declarative_base()

Expand Down Expand Up @@ -87,17 +85,6 @@ class VersionErrorTable(Base):
analysisversion = relationship("AnalysisVersion")


class MaterializedMetadata(MatBase):
__tablename__ = "materializedmetadata"
id = Column(Integer, primary_key=True)
schema = Column(String(100), nullable=False)
table_name = Column(String(100), nullable=False)
row_count = Column(Integer, nullable=False)
materialized_timestamp = Column(DateTime, nullable=False)
segmentation_source = Column(String(255), nullable=True)
is_merged = Column(Boolean, nullable=True)


class AnnoMetadata(Base):
__tablename__ = "annotation_table_metadata"
id = Column(Integer, primary_key=True)
Expand All @@ -123,6 +110,7 @@ class AnnoMetadata(Base):
nullable=False,
)
last_modified = Column(DateTime, nullable=False)
keep_created_ts_col = Column(Boolean, nullable=False)


class SegmentationMetadata(Base):
Expand Down