|
| 1 | +"""Add function access rights |
| 2 | +
|
| 3 | +Revision ID: 275642b33db0 |
| 4 | +Revises: e89eae27fb3f |
| 5 | +Create Date: 2025-05-30 07:45:32.807899+00:00 |
| 6 | +
|
| 7 | +""" |
| 8 | + |
| 9 | +import sqlalchemy as sa |
| 10 | +from alembic import op |
| 11 | +from sqlalchemy.dialects import postgresql |
| 12 | + |
| 13 | +# revision identifiers, used by Alembic. |
| 14 | +revision = "275642b33db0" |
| 15 | +down_revision = "e89eae27fb3f" |
| 16 | +branch_labels = None |
| 17 | +depends_on = None |
| 18 | + |
| 19 | + |
| 20 | +def upgrade(): |
| 21 | + # ### commands auto generated by Alembic - please adjust! ### |
| 22 | + op.create_table( |
| 23 | + "funcapi_function_job_collections_access_rights", |
| 24 | + sa.Column( |
| 25 | + "function_job_collection_uuid", |
| 26 | + postgresql.UUID(as_uuid=True), |
| 27 | + nullable=False, |
| 28 | + ), |
| 29 | + sa.Column("group_id", sa.BigInteger(), nullable=True), |
| 30 | + sa.Column("read", sa.Boolean(), nullable=True), |
| 31 | + sa.Column("write", sa.Boolean(), nullable=True), |
| 32 | + sa.Column("execute", sa.Boolean(), nullable=True), |
| 33 | + sa.Column( |
| 34 | + "created", |
| 35 | + sa.DateTime(timezone=True), |
| 36 | + server_default=sa.text("now()"), |
| 37 | + nullable=False, |
| 38 | + ), |
| 39 | + sa.Column( |
| 40 | + "modified", |
| 41 | + sa.DateTime(timezone=True), |
| 42 | + server_default=sa.text("now()"), |
| 43 | + nullable=False, |
| 44 | + ), |
| 45 | + sa.ForeignKeyConstraint( |
| 46 | + ["function_job_collection_uuid"], |
| 47 | + ["funcapi_function_job_collections.uuid"], |
| 48 | + name="fk_func_access_to_func_job_colls_to_func_job_coll_uuid", |
| 49 | + onupdate="CASCADE", |
| 50 | + ondelete="CASCADE", |
| 51 | + ), |
| 52 | + sa.ForeignKeyConstraint( |
| 53 | + ["group_id"], |
| 54 | + ["groups.gid"], |
| 55 | + name="fk_func_access_to_groups_group_id", |
| 56 | + onupdate="CASCADE", |
| 57 | + ondelete="CASCADE", |
| 58 | + ), |
| 59 | + sa.PrimaryKeyConstraint( |
| 60 | + "function_job_collection_uuid", |
| 61 | + "group_id", |
| 62 | + name="pk_func_access_to_func_job_colls_group", |
| 63 | + ), |
| 64 | + ) |
| 65 | + op.create_table( |
| 66 | + "funcapi_functions_access_rights", |
| 67 | + sa.Column("function_uuid", postgresql.UUID(as_uuid=True), nullable=False), |
| 68 | + sa.Column("group_id", sa.BigInteger(), nullable=False), |
| 69 | + sa.Column("read", sa.Boolean(), nullable=True), |
| 70 | + sa.Column("write", sa.Boolean(), nullable=True), |
| 71 | + sa.Column("execute", sa.Boolean(), nullable=True), |
| 72 | + sa.Column( |
| 73 | + "created", |
| 74 | + sa.DateTime(timezone=True), |
| 75 | + server_default=sa.text("now()"), |
| 76 | + nullable=False, |
| 77 | + ), |
| 78 | + sa.Column( |
| 79 | + "modified", |
| 80 | + sa.DateTime(timezone=True), |
| 81 | + server_default=sa.text("now()"), |
| 82 | + nullable=False, |
| 83 | + ), |
| 84 | + sa.ForeignKeyConstraint( |
| 85 | + ["function_uuid"], |
| 86 | + ["funcapi_functions.uuid"], |
| 87 | + name="fk_func_access_to_func_to_func_uuid", |
| 88 | + onupdate="CASCADE", |
| 89 | + ondelete="CASCADE", |
| 90 | + ), |
| 91 | + sa.ForeignKeyConstraint( |
| 92 | + ["group_id"], |
| 93 | + ["groups.gid"], |
| 94 | + name="fk_func_access_to_groups_group_id", |
| 95 | + onupdate="CASCADE", |
| 96 | + ondelete="CASCADE", |
| 97 | + ), |
| 98 | + sa.PrimaryKeyConstraint( |
| 99 | + "function_uuid", "group_id", name="pk_func_access_to_func_group" |
| 100 | + ), |
| 101 | + ) |
| 102 | + op.create_table( |
| 103 | + "funcapi_function_jobs_access_rights", |
| 104 | + sa.Column("function_job_uuid", postgresql.UUID(as_uuid=True), nullable=False), |
| 105 | + sa.Column("group_id", sa.BigInteger(), nullable=False), |
| 106 | + sa.Column("read", sa.Boolean(), nullable=True), |
| 107 | + sa.Column("write", sa.Boolean(), nullable=True), |
| 108 | + sa.Column("execute", sa.Boolean(), nullable=True), |
| 109 | + sa.Column( |
| 110 | + "created", |
| 111 | + sa.DateTime(timezone=True), |
| 112 | + server_default=sa.text("now()"), |
| 113 | + nullable=False, |
| 114 | + ), |
| 115 | + sa.Column( |
| 116 | + "modified", |
| 117 | + sa.DateTime(timezone=True), |
| 118 | + server_default=sa.text("now()"), |
| 119 | + nullable=False, |
| 120 | + ), |
| 121 | + sa.ForeignKeyConstraint( |
| 122 | + ["function_job_uuid"], |
| 123 | + ["funcapi_function_jobs.uuid"], |
| 124 | + name="fk_func_access_to_func_jobs_to_func_job_uuid", |
| 125 | + onupdate="CASCADE", |
| 126 | + ondelete="CASCADE", |
| 127 | + ), |
| 128 | + sa.ForeignKeyConstraint( |
| 129 | + ["group_id"], |
| 130 | + ["groups.gid"], |
| 131 | + name="fk_func_access_to_groups_group_id", |
| 132 | + onupdate="CASCADE", |
| 133 | + ondelete="CASCADE", |
| 134 | + ), |
| 135 | + sa.PrimaryKeyConstraint( |
| 136 | + "function_job_uuid", "group_id", name="pk_func_access_to_func_jobs_group" |
| 137 | + ), |
| 138 | + ) |
| 139 | + # ### end Alembic commands ### |
| 140 | + |
| 141 | + |
| 142 | +def downgrade(): |
| 143 | + # ### commands auto generated by Alembic - please adjust! ### |
| 144 | + op.drop_table("funcapi_function_jobs_access_rights") |
| 145 | + op.drop_table("funcapi_functions_access_rights") |
| 146 | + op.drop_table("funcapi_function_job_collections_access_rights") |
| 147 | + # ### end Alembic commands ### |
0 commit comments