Skip to content

Commit

Permalink
fixed migration script with permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
nevoodoo committed Jul 10, 2024
1 parent 1dfab53 commit 4c467d4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
1 change: 1 addition & 0 deletions db/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1449,6 +1449,7 @@

</addColumn>
</changeSet>

<changeSet id="2024-06-05_project_member_table" author="dan.coates">
<sql>SET @@system_versioning_alter_history = 1;</sql>
<createTable tableName="project_member">
Expand Down
31 changes: 21 additions & 10 deletions scripts/migrate_analysis_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@

from databases import Database

from db.python.connect import Connection, CredentialedDatabaseConfiguration
from db.python.connect import (
Connection,
CredentialedDatabaseConfiguration,
SMConnections,
)
from db.python.tables.output_file import OutputFileTable


Expand All @@ -15,7 +19,8 @@ def _get_connection_string():

# config = CredentialedDatabaseConfiguration(dbname='sm_dev', username='root')

return config.get_connection_string()
# return config.get_connection_string()
return config


async def get_analyses_without_fileid(connection: Database):
Expand All @@ -42,16 +47,22 @@ async def get_analyses_without_fileid(connection: Database):
async def main():
"""Go through all analysis objects and create output file objects where possible"""
connection_string = _get_connection_string()
database = Database(connection_string or _get_connection_string(), echo=True)
connection = Connection(
connection=database,
project=None,
author='migrate_output_files',
on_behalf_of='yash',
readonly=False,
database = Database(connection_string.get_connection_string(), echo=True)

sm_db = SMConnections.make_connection(
config=connection_string,
)
await sm_db.connect()
formed_connection = Connection(
connection=sm_db,
author='yash',
project_id_map={},
project_name_map={},
on_behalf_of=None,
ar_guid=None,
project=None,
)
oft = OutputFileTable(connection)
oft = OutputFileTable(formed_connection)
analyses = await get_analyses_without_fileid(database)
for analyis in analyses:
await oft.process_output_for_analysis(
Expand Down

0 comments on commit 4c467d4

Please sign in to comment.