diff --git a/dribdat/user/models.py b/dribdat/user/models.py index 041a6af6..32ca0937 100644 --- a/dribdat/user/models.py +++ b/dribdat/user/models.py @@ -1514,7 +1514,7 @@ class Activity(PkModel): class Resource(PkModel): """A framework, model, or tool used in a project.""" - __tablename__ = "resources" + __tablename__ = "resource" name = Column(db.String(80), nullable=False) source_url = Column(db.String(2048), nullable=True) type = Column(db.String(80), nullable=True) # model, tool, dataset, ... diff --git a/migrations/versions/ac23802e6154_add_resource_model.py b/migrations/versions/ac23802e6154_add_resource_model.py deleted file mode 100644 index e45b3a96..00000000 --- a/migrations/versions/ac23802e6154_add_resource_model.py +++ /dev/null @@ -1,46 +0,0 @@ -"""Add Resource model - -Revision ID: ac23802e6154 -Revises: be6bc930546b -Create Date: 2026-03-22 19:50:37.772830 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'ac23802e6154' -down_revision = 'be6bc930546b' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('resources', - sa.Column('name', sa.String(length=80), nullable=False), - sa.Column('source_url', sa.String(length=2048), nullable=True), - sa.Column('type', sa.String(length=80), nullable=True), - sa.Column('description', sa.UnicodeText(), nullable=True), - sa.Column('license', sa.String(length=256), nullable=True), - sa.Column('project_id', sa.Integer(), nullable=True), - sa.Column('id', sa.Integer(), nullable=False), - sa.ForeignKeyConstraint(['project_id'], ['projects.id'], ), - sa.PrimaryKeyConstraint('id') - ) - with op.batch_alter_table('projects_version', schema=None) as batch_op: - batch_op.create_index('ix_projects_version_pk_transaction_id', ['id', sa.literal_column('transaction_id DESC')], unique=False) - batch_op.create_index('ix_projects_version_pk_validity', ['id', 'transaction_id', 'end_transaction_id'], unique=False) - - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('projects_version', schema=None) as batch_op: - batch_op.drop_index('ix_projects_version_pk_validity') - batch_op.drop_index('ix_projects_version_pk_transaction_id') - - op.drop_table('resources') - # ### end Alembic commands ### diff --git a/migrations/versions/be6bc930546b_ranking.py b/migrations/versions/be6bc930546b_.py similarity index 100% rename from migrations/versions/be6bc930546b_ranking.py rename to migrations/versions/be6bc930546b_.py diff --git a/migrations/versions/efbe8a1c4eab_.py b/migrations/versions/efbe8a1c4eab_.py new file mode 100644 index 00000000..fac8a12d --- /dev/null +++ b/migrations/versions/efbe8a1c4eab_.py @@ -0,0 +1,59 @@ +"""create a resource table linked to projects + +Revision ID: efbe8a1c4eab +Revises: be6bc930546b +Create Date: 2026-04-09 00:11:44.724195 + +""" + +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = "efbe8a1c4eab" +down_revision = "be6bc930546b" +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table( + "resource", + sa.Column("name", sa.String(length=80), nullable=False), + sa.Column("source_url", sa.String(length=2048), nullable=True), + sa.Column("type", sa.String(length=80), nullable=True), + sa.Column("description", sa.UnicodeText(), nullable=True), + sa.Column("license", sa.String(length=256), nullable=True), + sa.Column("project_id", sa.Integer(), nullable=True), + sa.Column("id", sa.Integer(), nullable=False), + sa.ForeignKeyConstraint( + ["project_id"], + ["projects.id"], + ), + sa.PrimaryKeyConstraint("id"), + ) + with op.batch_alter_table("projects_version", schema=None) as batch_op: + batch_op.create_index( + "ix_projects_version_pk_transaction_id", + ["id", sa.literal_column("transaction_id DESC")], + unique=False, + ) + batch_op.create_index( + "ix_projects_version_pk_validity", + ["id", "transaction_id", "end_transaction_id"], + unique=False, + ) + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table("projects_version", schema=None) as batch_op: + batch_op.drop_index("ix_projects_version_pk_validity") + batch_op.drop_index("ix_projects_version_pk_transaction_id") + + op.drop_table("resource") + # ### end Alembic commands ###