emilpriver / geni

Standalone database migration tool which works for Postgres, MariaDB, MySQL, Sqlite and LibSQL(Turso).
MIT License
182 stars 1 forks source link

schema.sql's statements should be separated by `;` for sqlite. #185

Closed sjunepark closed 1 week ago

sjunepark commented 1 week ago

Current output for schema.sql


--
-- Sqlite SQL Schema dump automatic generated by geni
--

CREATE TABLE schema_migrations (id VARCHAR(255) PRIMARY KEY)
CREATE TABLE company
(
    id                           TEXT PRIMARY KEY NOT NULL CHECK ( length(id) = 10 ),
    representative_name          TEXT             NOT NULL,
    headquarters_address         TEXT             NOT NULL,
    business_registration_number TEXT UNIQUE      NOT NULL CHECK ( length(business_registration_number) = 10 ),
    company_name                 TEXT             NOT NULL,
    industry_code                TEXT             NOT NULL CHECK ( length(industry_code) = 5 ),
    industry_name                TEXT             NOT NULL
)
sjunepark commented 1 week ago

Seems like a very minor fix, but I don't have the time to look through the source code for now. I'll also try to come back to it if it's not fixed in the future.

emilpriver commented 1 week ago

Hey, Fixing! Thank you for reporting it

emilpriver commented 1 week ago

Which database are you using?

sjunepark commented 1 week ago

@emilpriver Wow that was fast. I'm using libsql in turso local dev mode.

Created the db using the turso cli command. turso dev --db-file db/local.db

Sorry for not providing a reproduction.

emilpriver commented 1 week ago

haha I was looking at my Github notifications almost the same second you created the issue :D

Seems to be a issue with sqlite which includes sqlite and libsql drivers. I am fetching this from sqlite_master table in your database so it should be enough with adding a simple ; to the code

emilpriver commented 1 week ago

Solved it

warning: `geni` (lib) generated 1 warning
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 2.62s
     Running `target/debug/geni up`
12:54:04 [INFO] Running migration 1726750162
CREATE TABLE schema_migrations (id VARCHAR(255) PRIMARY KEY);
CREATE TABLE company
(
    id                           TEXT PRIMARY KEY NOT NULL CHECK ( length(id) = 10 ),
    representative_name          TEXT             NOT NULL,
    headquarters_address         TEXT             NOT NULL,
    business_registration_number TEXT UNIQUE      NOT NULL CHECK ( length(business_registration_number) = 10 ),
    company_name                 TEXT             NOT NULL,
    industry_code                TEXT             NOT NULL CHECK ( length(industry_code) = 5 ),
    industry_name                TEXT             NOT NULL
);
12:54:04 [INFO] Success
sjunepark commented 1 week ago

@emilpriver That's nice. Thanks have a great day!

emilpriver commented 1 week ago

@emilpriver That's nice. Thanks have a great day!

u2!