Rename resources table to resource

This commit is contained in:
Oleg Lavrovsky 2026-04-09 00:13:10 +02:00
commit b14208166b
No known key found for this signature in database
GPG key ID: 31E523030632FF4B
4 changed files with 60 additions and 47 deletions

View file

@ -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, ...

View file

@ -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 ###

View file

@ -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 ###