django applying migrations but database empty

badiudragos
PRO

4 months ago

I have initialized a new DB because I've been having problems with viewing the database within Railway dashboard and it seems like my backend is applying migrations, I am able to register via my front end, however, when I go to my Railway Postgres service to view the data, there are no tables. Does anyone know what could be going wrong ?

Solved

0 Replies

badiudragos
PRO

4 months ago

740bdf7f-248a-4096-9001-688bbb7a239e


badiudragos
PRO

4 months ago

It also seems like there is now a 4th service (the one simply called Postgres) when I try to link from the CLI. I have never initialized this service myself.

1348541983907512300


maddsua
HOBBY

4 months ago

Well those tables seem to be in schemas different from 'public', and the railway's data tab defaults to 'public'


maddsua
HOBBY

4 months ago

U can try connecting with psql, it would be able to show all schemas


badiudragos
PRO

4 months ago

So I connected to it with dbgate and it was showing me that it was empty. I then succeeded to connect to it from local CLI using the public url and pushed migrations from my local environment. However when I connect to sign up via the online frontend service and create an account, the account that I create doesn't appear in the service's DB. Which makes me think that the data is going somewhere else, perhaps that "Postgres" service that I see in the CLI but not in my project dashboard. I don't know why it would go there however as all my backend variables point to the r4EZ one …

1348548939992793000
1348548940299108400


maddsua
HOBBY

4 months ago

Oh, I see


badiudragos
PRO

4 months ago

Something else that I find off is that these migrations I see in the deploy logs of my backend service, I never prompt them anywhere, I don't have a pre deploy command or anything setup to apply migrations anywhere in my backend so idk where this even comes from.

1348550833339371500


4 months ago

few things -

> It also seems like there is now a 4th service (the one simply called Postgres)

Yep that is the database in the development environment.

> Something else that I find off is that these migrations I see in the deploy logs of my backend service, I never prompt them anywhere

You aren't, its the default though -

As for where the migrations are going, no clue, all I know is that you do not have the correct variables set, for example, you use DB_USER in code, and have PGUSER set on your service.


badiudragos
PRO

4 months ago

So I have fixed the variables, ended up getting name or service not found on backend service deployment, fixed that by changing backend runtime to V2 instead of legacy like I've seen in another thread. I then tried to create a new user in the initialized and EMPTY DB and it was telling me that this email is already in use, odd. I then deleted the DB made another one, (given that migrations should be applied by nixpacks) backend applies the migrations but the DB still doesn't have any tables.

1348715259300675600
1348715259673841700
1348715259925495800


badiudragos
PRO

4 months ago

TLDR: Correct variables being used yet still backend doesn't seem to push migrations to the postgres service


badiudragos
PRO

4 months ago

solutionISH: changed from using 5 database variables to using database URL. still unsure why it wasn't working, I checked many times


4 months ago

glad you found the problem


4 months ago

!s


Status changed to Solved brody 4 months ago