Hi there! How to do a db migration. Is there any s...
# support
c
Hi there! How to do a db migration. Is there any specific command? Its regarding the rudder-server.
m
Hey There! 👋 Your message has been received by the RudderStack team. Our standard customer support hours are 9-6 PM EST, but we will forward this request to your Technical Account Manager, and they will get back to you shortly. Please use the thread for any additional comments.
Hi Sauparna, are you using the self-hosted data-plane? I can't see why you would need to migrate the DB.
c
Yes, self hosted.
Do we have any command for running a migration?
m
Which DB do you want to migrate?
c
The default jobsdb itself. We were using an older version of rudder-server and transformer. No we took the latest release of the service. But when we connect the service to our old db the migrations failed and what we saw was that workspace_id column was not getting added. Before addition of the column workspace id indexing migrations were getting executed.
Copy code
error while running changesets that run always in 'gw' jobsdb tables: run migration from template directory "jobsdb_always", migration failed: column "workspace_id" does not exist in line 0:
    CREATE INDEX IF NOT EXISTS "idx_gw_jobs_2_ws" ON "gw_jobs_2" (workspace_id);

    CREATE INDEX IF NOT EXISTS "idx_gw_jobs_5_ws" ON "gw_jobs_5" (workspace_id);
m
Hi Sauparna Gupta, I am checking with the team and will get back to you on this.
c
ok
Hi @mysterious-receptionist-5266, if you have any idea on the above please provide some insight.
I think the jobsdb_always migration is running before jobsdb migration but jobsdb_always migration has dependency with the later.
Copy code
error while running changesets that run always in 'gw' jobsdb tables: run migration from template directory "jobsdb_always", migration failed: column "workspace_id" does not exist in line 0:
    CREATE INDEX IF NOT EXISTS "idx_gw_jobs_2_ws" ON "gw_jobs_2" (workspace_id);

    CREATE INDEX IF NOT EXISTS "idx_gw_jobs_5_ws" ON "gw_jobs_5" (workspace_id);
Copy code
{{range .Datasets}}
    ALTER TABLE "{{$.Prefix}}_jobs_{{.}}" ADD COLUMN IF NOT EXISTS workspace_id TEXT NOT NULL DEFAULT '';
{{end}}
The above migration which is supposed to create the workspace_id is not running because the function which is supposed to run is not getting triggered.
Since jd.ownerType is "READ" in line 849, write boolean variable is set to false. Thereby jd.setupDatabaseTables in line 873 is not getting executed which is responsible for running jobsdb migrations.
@shy-kite-21035 please checkout the above details.
g
Which rudder-server version are you using @cold-portugal-29638 ? You shouldn't need to run the migration on your own
c
The rudder-server version being used is 1.11.1. The auto migration which is triggered when the server starts is failing because the migration that adds indexing on workspace_id on gw_jobs table is running prior to the migration that adds workspace_id on gw_jobs.
As you can see from the debug server the runAlwaysChangesets that is responsible to run migrations of jobsdb_always is getting triggered first. Even before setupDatabaseTables that is responsible to run migrations of jobsdb.
m
Hi @cold-portugal-29638 this should solve your issue. Hopefully, a new patch release will happen today https://github.com/rudderlabs/rudder-server/pull/3714
🙌 1
1.11.4 is now available
🙌 1
c
Thanks