I need help on deploying my development database to production without losing any data

I mistakenly ran the command npx prisma migrate dev on my production env but did not accept when the message says that it would result in resting the database Basically what I have been doing until now is developing all our backend and database migrations on a development branch and merging them in production branch and applying the migration to production env with npx prisma db push but know when I ran npx prisma migrate dev it would reset the database, and I am afraid of running npx prisma db push and not even give me the change of canceling if it resets my database this is the message
Drift detected: Your database schema is not in sync with your migration history.

The following is a summary of the differences between the expected database schema given your migrations files, and the actual schema of the database.

It should be understood as the set of changes to get from the expected schema to the actual schema.

[+] Added tables
- profiles

[-] Removed tables
- ChallengeParticipant
- Dalahast
- Land

[*] Changed the `ChallengeVote` table
[+] Added column `message`

[*] Changed the `User` table
[-] Removed foreign key on columns (challengeParticipantId)
[-] Removed unique index on columns (email)
[-] Removed column `challengeParticipantId`
[-] Removed column `email`

[*] Changed the `profiles` table
[+] Added unique index on columns (email)
[+] Added unique index on columns (userId)
[+] Added unique index on columns (username)
[+] Added foreign key on columns (userId)

We need to reset the "public" schema at
Drift detected: Your database schema is not in sync with your migration history.

The following is a summary of the differences between the expected database schema given your migrations files, and the actual schema of the database.

It should be understood as the set of changes to get from the expected schema to the actual schema.

[+] Added tables
- profiles

[-] Removed tables
- ChallengeParticipant
- Dalahast
- Land

[*] Changed the `ChallengeVote` table
[+] Added column `message`

[*] Changed the `User` table
[-] Removed foreign key on columns (challengeParticipantId)
[-] Removed unique index on columns (email)
[-] Removed column `challengeParticipantId`
[-] Removed column `email`

[*] Changed the `profiles` table
[+] Added unique index on columns (email)
[+] Added unique index on columns (userId)
[+] Added unique index on columns (username)
[+] Added foreign key on columns (userId)

We need to reset the "public" schema at
8 Replies
Percy
Percy16mo ago
Project ID: 1862ff4f-3f51-4d9c-a0c3-26d926471f99
ojoaoguilherme
ojoaoguilhermeOP16mo ago
1862ff4f-3f51-4d9c-a0c3-26d926471f99
Brody
Brody16mo ago
you are responsible for your own data, railway will not be held accountable for data loss caused by the user
Adam
Adam16mo ago
your databases should not be stored in the main service. This is what’s causing the loss of data create a new db service and store your data there
ojoaoguilherme
ojoaoguilhermeOP16mo ago
I didnt loose any data this is what I am trying to understand, I understood that there must be incosistent database schema from my development and main branch but when I merge I dont expect to loose data how should I do it in a way to avoid these loss? what do you mean my database should not stored in the main service? also is there a way to know which data I will loose before running prisma migrate deploy because what I am doing as metioned before is having 2 env PRODUCTION and DEVELOPMENT as normal, DEVELOPMENT is always ahead of PRODUCTION when I finish a feature I merge DEVELOPMENT to PRODUCTION and push the changes,
Brody
Brody16mo ago
these are more so questions for the prisma docs
ojoaoguilherme
ojoaoguilhermeOP16mo ago
now whats happening is before pushing the changes I want to update my PRODUCTION database schema with the updates that came from DEVELOPMENT on merge on DEVELOPMENT there are some tables I am droping and some required and unique fields that are not unique anymore, by running prisma migrate deploy or prisma db push can I know before running this the result of my database its ok to loose data that I intend but not resetting the database
Want results from more Discord servers?
Add your server