Skip to content

Preparations of some tables to migrate #7477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

__all__: tuple[str, ...] = (
"metadata",
"webserver_models",
"storage_models",
"webserver_models",
)

# nopycln: file
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@

__all__: tuple[str, ...] = (
"CheckViolation",
"DatabaseError",
"DataError",
"DBAPIError",
"DataError",
"DatabaseError",
"ForeignKeyViolation",
"IntegrityError",
"InterfaceError",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
""" command line interface for migration

"""
"""command line interface for migration"""

# pylint: disable=wildcard-import
# pylint: disable=unused-wildcard-import
Expand Down Expand Up @@ -127,7 +125,7 @@ def _test_swarm() -> dict:

return cfg

except Exception as err: # pylint: disable=broad-except # noqa: PERF203
except Exception as err: # pylint: disable=broad-except
inline_msg = str(err).replace("\n", ". ")
click.echo(f"<- {test.__name__} failed : {inline_msg}")

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"""drop user_to_projects

Revision ID: e33493b49140
Revises: 0d52976dc616
Create Date: 2025-05-01 20:06:49.642271+00:00

"""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "e33493b49140"
down_revision = "0d52976dc616"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table("user_to_projects")
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"user_to_projects",
sa.Column("id", sa.BIGINT(), autoincrement=True, nullable=False),
sa.Column("user_id", sa.BIGINT(), autoincrement=False, nullable=False),
sa.Column("project_id", sa.BIGINT(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(
["project_id"],
["projects.id"],
name="fk_user_to_projects_id_projects",
onupdate="CASCADE",
ondelete="CASCADE",
),
sa.ForeignKeyConstraint(
["user_id"],
["users.id"],
name="fk_user_to_projects_id_users",
onupdate="CASCADE",
ondelete="CASCADE",
),
sa.PrimaryKeyConstraint("id", name="user_to_projects_pkey"),
)
# ### end Alembic commands ###
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
""" User's confirmations table
"""User's confirmations table

- Keeps a list of tokens to identify an action (registration, invitation, reset, etc) authorized
by link to a a user in the framework
- These tokens have an expiration date defined by configuration
- Keeps a list of tokens to identify an action (registration, invitation, reset, etc) authorized
by link to a a user in the framework
- These tokens have an expiration date defined by configuration

Migration strategy:
- The primary key is `code`, which is unique and sufficient for migration.
- Ensure `user_id` foreign key references are valid in the target database.
- No additional changes are required; this table can be migrated as is.
"""

import enum

import sqlalchemy as sa
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
""" Groups table
"""Groups table

- List of groups in the framework
- Groups have a ID, name and a list of users that belong to the group
"""
- Represents user groups in the system.

Migration strategy:
- The primary key is `id`, which is unique and sufficient for migration.
- Ensure foreign key references (if any) are valid in the target database.
- No additional changes are required; this table can be migrated as is.
"""

import sqlalchemy as sa
from common_library.groups_enums import GroupType
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
""" Collection of jinja2 templates for customizable docs (e.g. emails, sites)
"""Jinja2 templates table

- Collection of jinja2 templates for customizable docs (e.g. emails, sites)

Migration strategy:
- The primary key is `id`, which is unique and sufficient for migration.
- No foreign key dependencies exist.
- No additional changes are required; this table can be migrated as is.
"""

import sqlalchemy as sa
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
"""Products table

- Represents products in the system.
- List of products served by the simcore platform
- Products have a name and an associated host (defined by a regex)
- Every product has a front-end with exactly the same name

Migration strategy:
- The primary key is `id`, which is unique and sufficient for migration.
- Ensure foreign key references (if any) are valid in the target database.
"""

from typing import Literal
Expand Down Expand Up @@ -123,6 +128,7 @@ class ProductLoginSettingsDict(TypedDict, total=False):
# NOTE: a default entry is created in the table Product
# see packages/postgres-database/src/simcore_postgres_database/migration/versions/350103a7efbd_modified_products_table.py


products = sa.Table(
"products",
metadata,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
"""Products to templates table

- Links products to Jinja2 templates.

Migration strategy:
- Composite primary key (`product_id`, `template_id`) is unique and sufficient for migration.
- Ensure foreign key references to `products` and `jinja2_templates` are valid in the target database.
- No additional changes are required; this table can be migrated as is.
"""

import sqlalchemy as sa

from ._common import (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
"""Projects table"""
"""Projects table

- Represents user projects in the system.

Migration strategy:
- The primary key is `id`, which is unique and sufficient for migration.
- Ensure foreign key references (if any) are valid in the target database.
- No additional changes are required; this table can be migrated as is.
"""

import enum

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
"""Projects comments table

- Stores comments associated with projects.

Migration strategy:
- The primary key is `id`, which is unique and sufficient for migration.
- Ensure foreign key references to `projects` are valid in the target database.
- No additional changes are required; this table can be migrated as is.
"""

import sqlalchemy as sa

from ._common import RefActions, column_created_datetime, column_modified_datetime
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
"""Projects networks table

- Represents networks associated with projects.

Migration strategy:
- The primary key is `id`, which is unique and sufficient for migration.
- Ensure foreign key references to `projects` are valid in the target database.
- No additional changes are required; this table can be migrated as is.
"""

import sqlalchemy as sa
from sqlalchemy.dialects.postgresql import JSONB

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
""" Groups table
"""Projects nodes table

- List of groups in the framework
- Groups have a ID, name and a list of users that belong to the group
- Represents nodes within projects.
- List of groups in the framework
- Groups have a ID, name and a list of users that belong to the group

Migration strategy:
- The primary key is `node_id`, which is unique and sufficient for migration.
- Ensure foreign key references to `projects` are valid in the target database.
- No additional changes are required; this table can be migrated as is.
"""

import sqlalchemy as sa
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
"""Projects tags table

- Links tags to projects.

Migration strategy:
- Composite primary key (`project_id`, `tag_id`) is unique and sufficient for migration.
- Ensure foreign key references to `projects` and `tags` are valid in the target database.
- No additional changes are required; this table can be migrated as is.
"""

import sqlalchemy as sa

from ._common import RefActions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
"""Projects to folders table

- Links projects to folders.

Migration strategy:
- Composite primary key (`project_id`, `folder_id`) is unique and sufficient for migration.
- Ensure foreign key references to `projects` and `folders` are valid in the target database.
- No additional changes are required; this table can be migrated as is.
"""

import sqlalchemy as sa

from ._common import RefActions, column_created_datetime, column_modified_datetime
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
"""Projects to products table

- Links projects to products.

Migration strategy:
- Composite primary key (`project_id`, `product_id`) is unique and sufficient for migration.
- Ensure foreign key references to `projects` and `products` are valid in the target database.
- No additional changes are required; this table can be migrated as is.
"""

import sqlalchemy as sa

from ._common import RefActions, column_created_datetime, column_modified_datetime
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
""" Stores SOME of the information associated to Research Resource Identifiers (RRIDs) as defined in https://scicrunch.org/resources
"""Scicrunch resources table

- Stores resources fetched from Scicrunch.
- Stores SOME of the information associated to Research Resource Identifiers (RRIDs) as defined in https://scicrunch.org/resources

Migration strategy:
- The primary key is `id`, which is unique and sufficient for migration.
- No foreign key dependencies exist.
- No additional changes are required; this table can be migrated as is.
"""

"""
"""

import sqlalchemy as sa
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
""" Services table
"""Services table

- List of 3rd party services in the framework
- Services have a key, version, and access rights defined by group ids
- List of 3rd party services in the framework
- Services have a key, version, and access rights defined by group ids
"""

from typing import NotRequired, Required

import sqlalchemy as sa
import typing_extensions
from sqlalchemy.dialects.postgresql import JSONB
from typing_extensions import NotRequired, Required

from ._common import (
RefActions,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
"""
Establishes which services can consume a given filetype
Services consume filetypes table

The relation is N-N because
- a service could handle one or more filetypes and
- one filetype could be handled by one or more services
- Links services to the file types they consume.
- Establishes which services can consume a given filetype
- The relation is N-N because
- a service could handle one or more filetypes and
- one filetype could be handled by one or more services

Migration strategy:
- Composite primary key (`service_key`, `filetype_id`) is unique and sufficient for migration.
- Ensure foreign key references to `services` and `filetypes` are valid in the target database.
- No additional changes are required; this table can be migrated as is.
"""

import sqlalchemy as sa

from ._common import RefActions
from .base import metadata

#
# TODO: This information SHALL be defined in service metadata upon publication
# and the catalog service, using e.g. a background task,
# can automatically fill this table with services that elligable (e.g. shared with everybody)
# to consume given filetypes. Notice also that service "matching" will also be determined in a near
# future by more complex metadata
#

services_consume_filetypes = sa.Table(
"services_consume_filetypes",
metadata,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
"""Tags table

- Represents tags that can be associated with various entities.

Migration strategy:
- The primary key is `id`, which is unique and sufficient for migration.
- Ensure foreign key references (if any) are valid in the target database.
- No additional changes are required; this table can be migrated as is.
"""

import sqlalchemy as sa

from .base import metadata
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
"""Tags access rights table

- Defines access rights for tags.

Migration strategy:
- Composite primary key (`tag_id`, `user_id`) is unique and sufficient for migration.
- Ensure foreign key references to `tags` and `users` are valid in the target database.
- No additional changes are required; this table can be migrated as is.
"""

import sqlalchemy as sa

from ._common import RefActions, column_created_datetime, column_modified_datetime
Expand Down
Loading
Loading