From f9e609b071f25cb12a0b37e3fe9acece768e5300 Mon Sep 17 00:00:00 2001 From: Arash Date: Thu, 19 Dec 2024 10:40:56 +0100 Subject: [PATCH] add user credentials, user credentials group, variable, and secret tables to migration --- ...64ee692df15b_add_user_credentials_table.py | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 lib/galaxy/model/migrations/alembic/versions_gxy/64ee692df15b_add_user_credentials_table.py diff --git a/lib/galaxy/model/migrations/alembic/versions_gxy/64ee692df15b_add_user_credentials_table.py b/lib/galaxy/model/migrations/alembic/versions_gxy/64ee692df15b_add_user_credentials_table.py new file mode 100644 index 000000000000..b29793b13dc7 --- /dev/null +++ b/lib/galaxy/model/migrations/alembic/versions_gxy/64ee692df15b_add_user_credentials_table.py @@ -0,0 +1,88 @@ +"""add user credentials table + +Revision ID: 64ee692df15b +Revises: 75348cfb3715 +Create Date: 2024-12-19 10:38:04.970502 + +""" + +from sqlalchemy import ( + Boolean, + Column, + DateTime, + ForeignKey, + Integer, +) + +from galaxy.model.custom_types import TrimmedString +from galaxy.model.database_object_names import build_foreign_key_name +from galaxy.model.migrations.util import ( + add_column, + create_table, + drop_constraint, + drop_table, +) + +# revision identifiers, used by Alembic. +revision = "64ee692df15b" +down_revision = "75348cfb3715" +branch_labels = None +depends_on = None + + +user_credentials_table = "user_credentials" +user_credentials_group_table = "user_credentials_group" +variable_table = "variable" +secret_table = "secret" + + +def upgrade(): + create_table( + user_credentials_table, + Column("id", Integer, primary_key=True), + Column("user_id", Integer, ForeignKey("galaxy_user.id"), index=True), + Column("reference", TrimmedString(255)), + Column("source_type", TrimmedString(255)), + Column("source_id", TrimmedString(255)), + Column("create_time", DateTime), + Column("update_time", DateTime), + ) + create_table( + user_credentials_group_table, + Column("id", Integer, primary_key=True), + Column("name", TrimmedString(255)), + Column("user_credentials_id", Integer, ForeignKey("user_credentials.id"), index=True), + Column("create_time", DateTime), + Column("update_time", DateTime), + ) + add_column( + user_credentials_table, + Column("current_group_id", Integer, ForeignKey("user_credentials_group.id"), index=True, nullable=True), + ) + create_table( + variable_table, + Column("id", Integer, primary_key=True), + Column("user_credential_group_id", Integer, ForeignKey("user_credentials_group.id"), index=True), + Column("name", TrimmedString(255)), + Column("value", TrimmedString(255)), + Column("create_time", DateTime), + Column("update_time", DateTime), + ) + create_table( + secret_table, + Column("id", Integer, primary_key=True), + Column("user_credential_group_id", Integer, ForeignKey("user_credentials_group.id"), index=True), + Column("name", TrimmedString(255)), + Column("already_set", Boolean), + Column("create_time", DateTime), + Column("update_time", DateTime), + ) + + +def downgrade(): + drop_constraint(build_foreign_key_name(user_credentials_table, "current_group_id"), user_credentials_table) + + drop_table(variable_table) + drop_table(secret_table) + drop_table(user_credentials_group_table) + drop_table(user_credentials_table)