All Postgresql data has been deleted
jnzin
HOBBYOP

a year ago

I have a node project that collects data every minute from an API and saves it in PostgresSQL using Prisma. It has been running for over a month.

Today, around 12:20 BRT (15:20 UTC), all the data was simply deleted. I asked other people who work on a project that connects to this database and none of them said they gave any command.

However, in the Postgres logs, at the same time, there is this log that deleted the migrations table from Prisma:

2024-08-31 15:21:47.116 UTC [59986] LOG:  could not receive data from client: Connection reset by peer

2024-08-31 15:21:54.102 UTC [60002] LOG:  could not receive data from client: Connection reset by peer

2024-08-31 15:21:58.479 UTC [60003] ERROR:  table "_prisma_migrations" does not exist

2024-08-31 15:21:58.479 UTC [60003] STATEMENT:  DROP TABLE _prisma_migrations

2024-08-31 15:22:00.860 UTC [36465] ERROR:  column Event.homeCountry does not exist at character 284

2024-08-31 15:22:00.860 UTC [36465] STATEMENT:  SELECT "public"."Event"."id", "public"."Event"."betsapiEventId", "public"."Event"."betfairEventId", "public"."Event"."leagueId", "public"."Event"."leagueName", "public"."Event"."leagueCountry", "public"."Event"."homeId", "public"."Event"."homeName", "public"."Event"."homeImageUrl", "public"."Event"."homeCountry", "public"."Event"."awayId", "public"."Event"."awayName", "public"."Event"."awayImageUrl", "public"."Event"."awayCountry", "public"."Event"."time", "public"."Event"."status"::text, "public"."Event"."homeOdds", "public"."Event"."awayOdds", "public"."Event"."drawOdds", "public"."Event"."totalMatched", "public"."Event"."ft", "public"."Event"."ht" FROM "public"."Event" WHERE (("public"."Event"."id") NOT IN (SELECT "t1"."eventId" FROM "public"."Pull" AS "t1" LEFT JOIN "public"."BetsApiData" AS "j2" ON ("j2"."id") = ("t1"."betsApiDataId") WHERE ("j2"."eventStatus" = CAST($1::text AS "public"."EventStatus") AND ("j2"."id" IS NOT NULL) AND "t1"."eventId" IS NOT NULL)) AND "public"."Event"."time" < $2 AND "public"."Event"."time" > $3) OFFSET $4

I believe someone executed some wrong Prisma command and caused this. Do you have any idea what could have happened?

I didn't make any backups, and this was my mistake, but if there was any way to recover this I would be very grateful. If not I would like to at least try to understand what happened. Thanks in advance.
Solved

3 Replies

itsrems
EMPLOYEE

a year ago

Hi Jonas.

It does look like someone went ahead and forcefully dropped tables in your database.

I'll forward this with the team so they can look if we have any backup, but by default, we don't preserve historical data of volumes.

In the future, I would recommend looking into this template: https://railway.app/template/I4zGrH to get backups setup.
Best,
Nicolas


Status changed to Awaiting User Response Railway over 1 year ago


jnzin
HOBBYOP

a year ago

Hi Jonas.

It does look like someone went ahead and forcefully dropped tables in your database.

I'll forward this with the team so they can look if we have any backup, but by default, we don't preserve historical data of volumes.

In the future, I would recommend looking into this template: https://railway.app/template/I4zGrH to get backups setup.
Best,
Nicolas

Hello friend, thanks for your reply.

We are already arranging for automatic backups to avoid this type of problem. Since we hadn't launched the system yet, we hadn't worried about it, but it was a mistake.

This problem ended up delaying our launch. If by some miracle you can get this data back, I would be eternally grateful, but I understand that it doesn't keep it by default.

Anyway, thanks for your attention.


Status changed to Awaiting Railway Response Railway over 1 year ago


Status changed to Solved chandrika over 1 year ago


Status changed to Open chandrika over 1 year ago


chandrika
EMPLOYEE

a year ago

Hi Jonas, unfortunately we aren't able to get the data back — thank you for understanding and wishing you our best to set things up with the new automatic backups you're planning on!


Status changed to Solved chandrika over 1 year ago


Loading...