Wipe Neon Database
I need to know how to wipe it, and how to remove registerd tables. Because I am in my testing phase and I need to wipe and add tables, along with register new columns in said tables. But I am not able to, Help is much appreciated.
6 Replies
It really is just me trying to push my changes with
npx drizzle-kit push:pg
. But it does not let me. First it asks if
· You're about to add item_market_id_unique unique constraint to the table, which contains 72 items. If this statement fails, you will receive an error from the database. Do you want to truncate item table?
Then I press yes, I have already tried no and it does not work.
Now when I proceed I get this:
Warning Found data-loss statements:
· You're about to change id column type from serial to uuid with 2 items
· You're about to add not-null namespaced_id column without default value, which contains 72 items
· You're about to delete id column in item table with 72 items
THIS ACTION WILL CAUSE DATA LOSS AND CANNOT BE REVERTED
Do you still want to push changes?
error: column "id" cannot be cast automatically to type uuid
at C:\Coding\Wimer\my-app\node_modules\drizzle-kit\bin.cjs:24462:21
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async PgPostgres.query (C:\Coding\Wimer\my-app\node_modules\drizzle-kit\bin.cjs:25423:21)
at async Command.<anonymous> (C:\Coding\Wimer\my-app\node_modules\drizzle-kit\bin.cjs:63261:9) {
length: 169,
severity: 'ERROR',
code: '42804',
detail: undefined,
hint: 'You might need to specify "USING id::uuid".',
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'tablecmds.c',
line: '12336',
routine: 'ATPrepAlterColumnType'
}
I am guessing this would be a common problem, but I am just clueless.
I am just trying to change a few fields in a table in my schema.
STILL NEED HELPThe easiest way is to just drop the table and push again. Normally you'd manage this with migrations, but since you're prototyping, it's easier to just drop the tables and push them again
if you want to keep your data, check this out https://cleanspeak.com/blog/2015/09/23/postgresql-int-to-uuid
How do I drop them?
personally, i use DBeaver (an open source SQL database tool) to view and manage my tables. From there you can right click your table and click DELETE to drop it. It also is able to cascade delete if there are other tables with a foreign key to that table. Very useful and worth learning to use
If you want to quickly do it though, just go on neon, select your project, then on the left click SQL editor. From there you can run sql queries. For ex, if your table is , just type
Thank you, this is my first time working with SQL