How to convert database plugin to volume with database?
I saw plugins are being sunsetted, is there a way to easily convert a plugin database ( i have a pq database) to a volume with db?
51 Replies
Project ID:
N/A
N/A
- deploy a new postgres database (it will automatically deploy the new database with a volume)
- use this tool that jr wrote to copy the data from the old plugin to the new service https://railway.app/template/postgres-plugin-migration
- swap the variable references from the old plugin to the new database
- redeploy your service
- profit
very cool, thanks!
I am getting an error: ==== Dumping database from PLUGIN_URL ====
pg_dump: warning: there are circular foreign-key constraints on this table:
pg_dump: detail: hypertable
pg_dump: hint: You might not be able to restore the dump without using --disable-triggers or temporarily dropping the constraints.
pg_dump: hint: Consider using a full dump instead of a --data-only dump to avoid this problem.
pg_dump: warning: there are circular foreign-key constraints on this table:
pg_dump: detail: chunk
pg_dump: hint: You might not be able to restore the dump without using --disable-triggers or temporarily dropping the constraints.
pg_dump: hint: Consider using a full dump instead of a --data-only dump to avoid this problem.
and here the actual error:
did you use timescale on your old database?
uhm its a directus cms database,
so i don't actually know the details of the structure
try the new migration template https://railway.app/template/postgres-plugin-migration
i just used that one
you sure, the one i previously linked is different
i am sure, i just did it a minute ago. searched for "postgres plugin migration" when i added a new service in my project
okay then i will directly report this to jr on monday
alright thanks!
FWIW i get the same error on a different project with a db that is not a directus cms db. The redis migration script did work though
jr would agree with me when I say this, this is very helpful information
Can you please share your project id @thomasmol
2ffb0267-37fb-4000-8d1e-e59b97ed85a8
thats for the project with a directus cms db
f9724669-2787-46a8-bfcd-3dd6e9944ba6 and this one is with a generic postgres db
you created your new database in a different project?
No i meant i tried the migration script in two different projects
Okay i saw the script was updated so tried again, seems to work! but i do get these warnings:
can i ignore these?
where you using the TimescaleDB extension?
tbh not that i know off
i am wondering why it was installed in the first place haha
the legacy plugins had the timescale extension installed by default
does the service (directus?) use timescale?
ah okay. just googled, directus does not use timescale
so should be fine then
but they do need postgis as ive just realized, the new database you migrate to must be postgis https://railway.app/template/postgis
can i enable that after the db is already deployed?
no since its not installed by default like it used to be
can't seem to deploy that template in my project
please explain why
the "save config" button and "deploy" button are disabled
leave beta from the account page
the new ghost template ui seems to be a bit broken right now
ah okay, got it working now all
thanks for the help
you got directus switched over to using a new database?
are you using the private network to communicate with the database?
yes i switched the directus db and another one as well
i am not using the private network currently
you'd want to use the private network, otherwise you will incur egress fees on the database
okay, so i just use the database_private_url then?
should do the job yeah
Mmm it works fine for the directus db but for my other one it does not, i get an P1001 error "can't reach database server"
what is the type of app that's not working with it?
sveltekit + prisma, running on nodejs
the non private db url works fine though
built with nixpacks?
yes
at what point in the apps lifecycle do you connect to the database?
it fails building, so it tries to connect at build time
ah, the private network is not available during build
okay interesting
you could run whatever it is before your app starts at runtime, but if you do that make sure you use a healthcheck so railway knows when your app has actually started
i think this is prisma trying to connect so i am not sure if i have control over this
you have more control than you think
I assume your build script runs prisma migrations?
yes it does
so just don't run the migrations during build
run them before your app starts instead
right, and then i use the health check in railway to notify when its done
wait could i just move the migration command to the start script?
is what i have now
fwiw, this worked so i got it running now with the private db url
also, the reason i wanted to migrate is because of the new deployment region select, as most of my users are in europe. So now i migrated all services to EU, and load times are now super fast 👍
haha yeah that's exactly what I said to do 🙂
but happy everything is working now!
Glad it is working! You can safely ignored the timescale message if you are not using it. Most projects will not being using Timescale