sync tries to always create a table
See original GitHub issueHi there.
following the examples to work on a small side-project I have.
if I use
export class SessionModel extends Model {
static table = "sessions";
static timestamps = true;
static fields = {
id: {
primaryKey: true,
autoIncrement: true,
},
startTimestamp: DATA_TYPES.INTEGER,
endTimestamp: DATA_TYPES.INTEGER,
createdAt: DATA_TYPES.INTEGER,
price: DATA_TYPES.STRING,
category: DATA_TYPES.STRING,
subCategory: DATA_TYPES.STRING,
state: DATA_TYPES.STRING,
withUser: DATA_TYPES.STRING,
notes: DATA_TYPES.STRING,
};
}
db.link([SessionModel]);
await db.sync({ drop: false /* true */ });
, the first time it runs, it creates the tables and everything is fine. Every time after that, it fails trying to create a table
( logs from my 2 containers, one with the postgres db, and one with the deno api )
bp-db_1 | 2020-05-24 19:40:10.668 UTC [306] ERROR: relation "sessions" already exists
bp-db_1 | 2020-05-24 19:40:10.668 UTC [306] STATEMENT: create table "sessions" ("id" serial primary key, "startTimestamp" integer, "endTimestamp" integer, "createdAt" integer, "price" varchar(255), "category" varchar(255), "subCategory" varchar(255), "state" varchar(255), "withUser" varchar(255), "notes" varchar(255), "created_at" timestamptz not null default CURRENT_TIMESTAMP, "updated_at" timestamptz not null default CURRENT_TIMESTAMP)
bp-api_1 | error: Uncaught PostgresError: relation "sessions" already exists
bp-api_1 | return new PostgresError(errorFields);
bp-api_1 | ^
bp-api_1 | at parseError (https://deno.land/x/postgres/error.ts:105:10)
bp-api_1 | at Connection._processError (https://deno.land/x/postgres/connection.ts:430:19)
bp-api_1 | at Connection._simpleQuery (https://deno.land/x/postgres/connection.ts:297:20)
bp-api_1 | at async Connection.query (https://deno.land/x/postgres/connection.ts:539:16)
bp-api_1 | at async Client.query (https://deno.land/x/postgres/client.ts:24:12)
bp-api_1 | at async PostgresConnector.query (https://deno.land/x/denodb/lib/connectors/postgres-connector.ts:45:21)
bp-api_1 | at async Function._createInDatabase (https://deno.land/x/denodb/lib/model.ts:75:5)
bp-api_1 | at async Promise.all (index 0)
bp-api_1 | at async file:///app/db.ts:32:1
If I switch drop
to true
, it will wipe out everything (after the first time)
I’m sure I’m missing something. How can I make it create the table only when it doesn’t exist??
Thank you.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Sequelize sync and Node.js not create table - Stack Overflow
In my case i just import Model to app.js const sequelize = require("./src/Utils/database"); const User = require(".
Read more >Data Factory auto create table in Copy activity doesn't seem to ...
I'm trying to create copy activities where the source table is replicated into the Sink database, and the table is created according to...
Read more >How to Use Airtable Sync - YouTube
This new tool gives us the ability to connect data across our Airtable bases (databases)! If you find yourself creating the same tables...
Read more >Airtable Sync - Basic Setup
The Airtable Sync feature allows you to sync records from a source base to one or more destination bases to create a single...
Read more >How to avoid Table Synchroniser... - Microsoft Dynamics AX ...
In your table, you have data with duplicate value in primary key/Unique index field. when you run Check/synchronization it will show the table...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey Antonis,
You are right, it actually tries to create the tables every single time. I will work on this right now and update this issue.
yeah, my bad, I forgot the “drop: true”. I removed that and it’s fine.
thanks 👍