Not able to create multiple tables in one schema.sql file
Version
1.17.2
What happened?
I'm trying to create multiple tables without having to create multiple tables. i get a syntax error schema.sql:1:1: syntax error at or near "CREATE"
are there any solutions or best practices?
Relevant log output
No response
Database schema
No response
SQL queries
No response
Configuration
No response
Playground URL
No response
What operating system are you using?
No response
What database engines are you using?
No response
What type of code are you generating?
No response
@aaliomer could you include your schema.sql file?
Possibly, the issue is that you have no semicolon between your CREATE TABLE statements. In this case, the first CREATE TABLE statement is not finished, and the second "CREATE TABLE" is part of the first statement, but unexpected, hence the error.
Facing the same issue! We do have semicolons. It works fine without locations table but getting error with it.
000001_create_tables.up.sql
CREATE TABLE IF NOT EXISTS trips (
trip_id VARCHAR(50) NOT NULL
);
CREATE TABLE IF NOT EXISTS locations (
car_id INTEGER NOT NULL
);
Error
000001_create_tables.up.sql:1:1: syntax error at or near "("
@sgielen I'm sorry I had an issue with one of my column's data type. I had specified col INTEGER(20) NOT NULL. The problem disappears after changing it to col INTEGER NOT NULL :)
the moral of the story is that the parser needs better error messages