Skip to content

Conversation

matusdrobuliak66
Copy link
Collaborator

@matusdrobuliak66 matusdrobuliak66 commented May 19, 2025

What do these changes do?

  • ♻️ Remove project comments resource (🗃️)
  • 🗃️ Add missing foreign keys
  • 🗃️ Add zzz_resource_tracker_service_runs__osparc_io_archive_202508 where we will archive osparc service runs data.zzz prefix is so it is in the end of all tables.

PLAN for index increment:

table increment column serial sequence name
api_keys id api_keys_id_seq
comp_runs run_id comp_runs_run_id_seq
comp_tasks task_id comp_tasks_task_id_seq
folders_v2 folder_id folders_v2_folder_id_seq
group_classifiers id group_classifiers_id_seq
groups gid groups_gid_seq
payments_autorecharge id payments_autorecharge_id_seq
projects_nodes project_node_id projects_nodes_project_node_id_seq
tags id tags_id_seq
tokens token_id tokens_token_id_seq
user_to_projects id user_to_projects_id_seq
users id users_id_seq
wallets wallet_id wallets_wallet_id_seq
workspaces workspace_id workspaces_workspace_id_seq

NOTE! resource_tracker_service_runs user ID needs to be manually incremented (foreign key can not be introduced, because all anonymous users are always deleted)

For migration:

-- users
UPDATE users SET id = id + 2000000;
SELECT setval('users_id_seq', (SELECT MAX(id) FROM users));
-- user_to_projects
UPDATE user_to_projects SET id = id + 2000000;
SELECT setval('user_to_projects_id_seq', (SELECT MAX(id) FROM user_to_projects));
-- EXPLICITELY resource_usage_tracker_service_runs (It is without the foreign key)
UPDATE resource_tracker_service_runs SET user_id = user_id + 2000000;

-- wallets
UPDATE wallets SET wallet_id = wallet_id + 2000000;
SELECT setval('wallets_wallet_id_seq', (SELECT MAX(wallet_id) FROM wallets));
-- workspaces
UPDATE workspaces SET workspace_id = workspace_id + 2000000;
SELECT setval('workspaces_workspace_id_seq', (SELECT MAX(workspace_id) FROM workspaces));
-- tokens
UPDATE tokens SET token_id = token_id + 2000000;
SELECT setval('tokens_token_id_seq', (SELECT MAX(token_id) FROM tokens));
-- tags
UPDATE tags SET id = id + 2000000;
SELECT setval('tags_id_seq', (SELECT MAX(id) FROM tags));
-- projects_nodes
UPDATE projects_nodes SET project_node_id = project_node_id + 2000000;
SELECT setval('projects_nodes_project_node_id_seq', (SELECT MAX(project_node_id) FROM projects_nodes));
-- payments_autorecharge
UPDATE payments_autorecharge SET id = id + 2000000;
SELECT setval('payments_autorecharge_id_seq', (SELECT MAX(id) FROM payments_autorecharge));
-- groups
UPDATE groups SET gid = gid + 2000000 where gid != 1;
SELECT setval('groups_gid_seq', (SELECT MAX(gid) FROM groups));
-- group_classifiers
UPDATE group_classifiers SET id = id + 2000000;
SELECT setval('group_classifiers_id_seq', (SELECT MAX(id) FROM group_classifiers));
-- folders_v2
UPDATE folders_v2 SET folder_id = folder_id + 2000000;
SELECT setval('folders_v2_folder_id_seq', (SELECT MAX(folder_id) FROM folders_v2));
-- comp_tasks
UPDATE comp_tasks SET task_id = task_id + 7000000;
SELECT setval('comp_tasks_task_id_seq', (SELECT MAX(task_id) FROM comp_tasks));
-- comp_runs
UPDATE comp_runs SET run_id = run_id + 2000000;
SELECT setval('comp_runs_run_id_seq', (SELECT MAX(run_id) FROM comp_runs));
-- api_keys
UPDATE api_keys SET id = id + 2000000;
SELECT setval('api_keys_id_seq', (SELECT MAX(id) FROM api_keys));

For archiving the runs table:

INSERT INTO zzz_resource_tracker_service_runs__osparc_io_archive_202508 (
    product_name,
    service_run_id,
    wallet_id,
    wallet_name,
    pricing_plan_id,
    pricing_unit_id,
    pricing_unit_cost_id,
    pricing_unit_cost,
    simcore_user_agent,
    user_id,
    user_email,
    project_id,
    project_name,
    node_id,
    node_name,
    parent_project_id,
    root_parent_project_id,
    root_parent_project_name,
    parent_node_id,
    root_parent_node_id,
    service_key,
    service_version,
    service_type,
    service_resources,
    service_additional_metadata,
    started_at,
    stopped_at,
    service_run_status,
    modified,
    last_heartbeat_at,
    service_run_status_msg,
    missed_heartbeat_counter
)
SELECT
    product_name,
    service_run_id,
    wallet_id,
    wallet_name,
    pricing_plan_id,
    pricing_unit_id,
    pricing_unit_cost_id,
    pricing_unit_cost,
    simcore_user_agent,
    user_id,
    user_email,
    project_id,
    project_name,
    node_id,
    node_name,
    parent_project_id,
    root_parent_project_id,
    root_parent_project_name,
    parent_node_id,
    root_parent_node_id,
    service_key,
    service_version,
    service_type::text::resourcetrackerservicetypeosparciohistory,
    service_resources,
    service_additional_metadata,
    started_at,
    stopped_at,
    service_run_status::text::resourcetrackerservicerunstatusosparciohistory,
    modified,
    last_heartbeat_at,
    service_run_status_msg,
    missed_heartbeat_counter
FROM resource_tracker_service_runs;

Related issue/s

How to test

Dev-ops

@matusdrobuliak66 matusdrobuliak66 changed the title ♻️ preparation for osparc migration (merging deployments) ♻️ preparation for osparc migration (merging deployments) (🗃️) May 19, 2025
Copy link

codecov bot commented May 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.63%. Comparing base (bd72ef7) to head (1426b48).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7700      +/-   ##
==========================================
+ Coverage   88.04%   88.63%   +0.59%     
==========================================
  Files        1919     1345     -574     
  Lines       74341    57271   -17070     
  Branches     1305      437     -868     
==========================================
- Hits        65450    50762   -14688     
+ Misses       8498     6391    -2107     
+ Partials      393      118     -275     
Flag Coverage Δ *Carryforward flag
integrationtests 63.93% <ø> (-0.25%) ⬇️ Carriedforward from 4c15e6c
unittests 88.38% <ø> (+1.69%) ⬆️

*This pull request uses carry forward flags. Click here to find out more.

Components Coverage Δ
pkg_aws_library ∅ <ø> (∅)
pkg_celery_library ∅ <ø> (∅)
pkg_dask_task_models_library ∅ <ø> (∅)
pkg_models_library 93.05% <ø> (ø)
pkg_notifications_library 85.26% <ø> (ø)
pkg_postgres_database ∅ <ø> (∅)
pkg_service_integration ∅ <ø> (∅)
pkg_service_library ∅ <ø> (∅)
pkg_settings_library ∅ <ø> (∅)
pkg_simcore_sdk 84.97% <ø> (ø)
agent 93.53% <ø> (ø)
api_server 92.84% <ø> (ø)
autoscaling 95.89% <ø> (ø)
catalog 92.34% <ø> (ø)
clusters_keeper 99.13% <ø> (ø)
dask_sidecar 92.37% <ø> (ø)
datcore_adapter 97.94% <ø> (ø)
director 75.81% <ø> (ø)
director_v2 90.89% <ø> (-0.03%) ⬇️
dynamic_scheduler 96.27% <ø> (ø)
dynamic_sidecar 90.10% <ø> (ø)
efs_guardian 89.62% <ø> (ø)
invitations 91.44% <ø> (ø)
payments ∅ <ø> (∅)
resource_usage_tracker ∅ <ø> (∅)
storage ∅ <ø> (∅)
webclient ∅ <ø> (∅)
webserver 84.44% <ø> (-3.66%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bd72ef7...1426b48. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@matusdrobuliak66 matusdrobuliak66 self-assigned this May 19, 2025
@matusdrobuliak66 matusdrobuliak66 marked this pull request as ready for review May 19, 2025 12:30
@matusdrobuliak66 matusdrobuliak66 added a:webserver webserver's codebase. Assigning the area is particularly useful for bugs a:database associated to postgres service and postgres-database package labels May 19, 2025
@matusdrobuliak66 matusdrobuliak66 added this to the Bazinga! milestone May 19, 2025
Copy link
Member

@sanderegg sanderegg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you try with the DBs already?
thanks!

@mrnicegyu11
Copy link
Member

I dont fully get what happens in this PR (what is CASCADE?) or the introduction of the zzz_resource_tracker_service_runs__osparc_io_archive_202508 table, but I also dont see blockers. :--)

Copy link
Member

@pcrespov pcrespov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx. Please double check mycomments. Specially theone of user_id

Copy link

Copy link
Contributor

mergify bot commented Aug 26, 2025

🧪 CI Insights

Here's what we observed from your CI run for 1426b48.

❌ Failed Jobs

Pipeline Job Health on base branch Retries 🔍 CI Insights 📄 Logs
CI integration-tests Healthy 0 View View
system-tests Healthy 0 View View
unit-tests Healthy 0 View View

@matusdrobuliak66 matusdrobuliak66 modified the milestones: Bazinga!, Voyager Aug 26, 2025
Copy link

@matusdrobuliak66 matusdrobuliak66 modified the milestones: Voyager, Cheops Sep 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a:database associated to postgres service and postgres-database package a:webserver webserver's codebase. Assigning the area is particularly useful for bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants