twentyhq / twenty

Building a modern alternative to Salesforce, powered by the community.
https://twenty.com
GNU Affero General Public License v3.0
15.77k stars 1.72k forks source link

`relation "core.user" does not exist` after upgrading v0.1.5 to v0.2.1 #3038

Closed joshuajung closed 8 months ago

joshuajung commented 9 months ago

Bug Description

I upgraded my self-hosted Twenty instance from v0.1.5 to v0.2.1 by switching to the new Docker images from Docker Hub. Now, when trying to sign in, I can see this error message in the client console:

{"errors":[{"message":"QueryFailedError","locations":[{"line":2,"column":3}],"path":["checkUserExists"],"extensions":{"code":"INTERNAL_SERVER_ERROR","response":"relation \"core.user\" does not exist"}}],"data":null}

Are there any migrations that need to be run manually? I found nothing in the Release Notes.

Expected behavior

Sign in works as usual.

charlesBochet commented 9 months ago

Ok, from 0.1.5 to 0.2.1, we have introduced many breaking changes. Do you have any data you want to keep? If not, I think the shortest way is to reset your database: yarn database:reset on server

charlesBochet commented 9 months ago

If you have data that's another story, I would say the shortest way is to create another database "default-new" that you can init through yarn database:init and then to move your stuff from the old to the new with SQL/Postgres client UI directly

joshuajung commented 9 months ago

Yes, we have a production instance of Twenty with quite a few records... maybe that was a bit naïve with the early version, but the team really enjoyed it. :-)

I'm not sure if I feel comfortable moving stuff by hand on a trial and error basis, to be honest. Do you think there is a chance that a migration script or instructions may become available at some point in time?

charlesBochet commented 9 months ago

@joshuajung Twenty is not production ready for self-hosting yet :( I think, when it will, we will release 1.0.0

In the meantime, we are happy to assist you manually. Could you open a thread in our discord #help channel and I can guide you on the best way to do it. We won't be able to provide script at this point but if you have a low number of record, it should be straight forward to migrate it to 0.2

joshuajung commented 8 months ago

Thank you @charlesBochet! I'll make sure to do that as soon as I have some time to follow up more or less in real time.

joshuajung commented 8 months ago

I'm finally back from my vacation and very motivated to get this done. :-)

I have set up an entirely new environment with a clean database and the v0.2.2 Docker images. However, the server Docker image no longer seems to automatically run migrations upon first launch. Is this intended? Should I run the migrations to create the initial database layout manually using the yarn database:setup:prod command?

charlesBochet commented 8 months ago

Hi @joshuajung! Yes it is intended in the current version. and yes you can run yarn nx database:setup:prod to setup your production database correctly :)

joshuajung commented 8 months ago

Thank you @charlesBochet!

Unfortunately, I didn't get far, as Google Cloud SQL (still our host) doesn't seem to support the pg_graphql extension (also as per https://github.com/orgs/supabase/discussions/6506). I guess I would have to run our own Postgres container, which would then be fully configurable.

For the moment, that's unfortunately too much effort for me, especially as the team seems to be happy on v0.1.5. I'll put our legacy installation behind a VPN for added security. keep an eye on you folks' progress and probably plan a big bang upgrade of our installation once you hit v1.0. :-)

charlesBochet commented 8 months ago

Ok, makes sense :) We will also probably provide pre-configured docker-compose and helm charts for self-hosting in the upcoming months

venkatesh22 commented 6 months ago

@charlesBochet @joshuajung How can we configure the database or execute migrations when we're self-hosting on AWS ECS Fargate using the default container images? i don't find a way to run the commands n aws ecs

charlesBochet commented 6 months ago

It looks like there is a bit of config to be done: https://dev.to/femilawal/how-to-ssh-into-an-ecs-fargate-container-1l3k