-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #599 from edraj/soheyb-v3
re-structuring
- Loading branch information
Showing
63 changed files
with
3,052 additions
and
2,556 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env -S BACKEND_ENV=config.env python3 | ||
from sqlmodel import select | ||
|
||
from data_adapters.sql.adapter import SQLAdapter | ||
from data_adapters.sql.create_tables import Entries, Permissions, Roles, Spaces, Users | ||
from utils.query_policies_helper import generate_query_policies | ||
|
||
|
||
print("[INFO] [dmart.script] Performing post-upgrade data migration (calc-query-policies)") | ||
with SQLAdapter().get_session() as session: | ||
for table in [Entries, Permissions, Roles, Spaces, Users]: | ||
print(f"[INFO] [dmart.script] Processing table: {table}") | ||
records = session.exec(select(table)).all() | ||
print(f"[INFO] [dmart.script] Processing {len(records)} records") | ||
for record in records: | ||
if not record.query_policies: | ||
record.query_policies = generate_query_policies( | ||
space_name=record.space_name, | ||
subpath=record.subpath, | ||
resource_type=record.resource_type, | ||
is_active=record.is_active, | ||
owner_shortname=record.owner_shortname, | ||
owner_group_shortname= record.owner_group_shortname if hasattr(record, 'owner_group_shortname') else "", | ||
) | ||
session.add(record) | ||
print(".", end="\r") | ||
session.commit() | ||
print("[INFO] [dmart.script] Post-upgrade data migration completed") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
backend/alembic/versions/f7a4949eed19_adding_query_policies_to_meta.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
"""adding query_policies to meta | ||
Revision ID: f7a4949eed19 | ||
Revises: 848b623755a4 | ||
Create Date: 2025-01-22 11:37:26.347777 | ||
""" | ||
from typing import Sequence, Union | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
import sqlmodel | ||
import sqlmodel.sql.sqltypes | ||
from sqlalchemy.dialects import postgresql | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = 'f7a4949eed19' | ||
down_revision: Union[str, None] = '848b623755a4' | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
with op.batch_alter_table('entries', schema=None) as batch_op: | ||
batch_op.add_column(sa.Column('query_policies', postgresql.ARRAY(sa.TEXT()), nullable=False, server_default='{}')) | ||
|
||
with op.batch_alter_table('permissions', schema=None) as batch_op: | ||
batch_op.add_column(sa.Column('query_policies', postgresql.ARRAY(sa.TEXT()), nullable=False, server_default='{}')) | ||
|
||
with op.batch_alter_table('roles', schema=None) as batch_op: | ||
batch_op.add_column(sa.Column('query_policies', postgresql.ARRAY(sa.TEXT()), nullable=False, server_default='{}')) | ||
|
||
with op.batch_alter_table('spaces', schema=None) as batch_op: | ||
batch_op.add_column(sa.Column('query_policies', postgresql.ARRAY(sa.TEXT()), nullable=False, server_default='{}')) | ||
|
||
with op.batch_alter_table('users', schema=None) as batch_op: | ||
batch_op.add_column(sa.Column('query_policies', postgresql.ARRAY(sa.TEXT()), nullable=False, server_default='{}')) | ||
|
||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
with op.batch_alter_table('users', schema=None) as batch_op: | ||
batch_op.drop_column('query_policies') | ||
|
||
with op.batch_alter_table('spaces', schema=None) as batch_op: | ||
batch_op.drop_column('query_policies') | ||
|
||
with op.batch_alter_table('roles', schema=None) as batch_op: | ||
batch_op.drop_column('query_policies') | ||
|
||
with op.batch_alter_table('permissions', schema=None) as batch_op: | ||
batch_op.drop_column('query_policies') | ||
|
||
with op.batch_alter_table('entries', schema=None) as batch_op: | ||
batch_op.drop_column('query_policies') | ||
|
||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.