Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialization of schema_migrations does not work when using sqlite #168

Open
svetlyak40wt opened this issue Mar 20, 2025 · 0 comments
Open

Comments

@svetlyak40wt
Copy link
Contributor

A minimal example to reproduce:

CL-USER> (let ((mito:*connection* (dbi:connect :sqlite3 :database-name #P"/tmp/myapp.db")))
              (unwind-protect
                   (mito.migration:migrate #P"/tmp/db/")
                (dbi:disconnect mito:*connection*)))

When executed in REPL it signals the error:

DB Error: near "?": syntax error (Code: ERROR)
   [Condition of type DBI.ERROR:DBI-PROGRAMMING-ERROR]

Restarts:
 0: [RETRY] Retry SLY mREPL evaluation request.
 1: [*ABORT] Return to SLY's top level.
 2: [ABORT] abort thread (#<THREAD tid=55641 "sly-channel-1-mrepl-remote-1" RUNNING {1000BB0003}>)

Backtrace:
 0: ((:METHOD DBI.DRIVER:PREPARE (DBD.SQLITE3:DBD-SQLITE3-CONNECTION STRING)) #<DBD.SQLITE3:DBD-SQLITE3-CONNECTION {1002B4F4B3}> "CREATE TABLE IF NOT EXISTS \"schema_migrations$
      Locals:
        #:.DEFAULTING-TEMP. = T
        DBD.SQLITE3::CONN = #<DBD.SQLITE3:DBD-SQLITE3-CONNECTION {1002B4F4B3}>
        DBD.SQLITE3::CONN-HANDLE = #<SQLITE:SQLITE-HANDLE {1002B4F413}>
        DBD.SQLITE3::E = #<SQLITE:SQLITE-ERROR "Could not prepare an sqlite statement." {1002F0DA83}>
        DBD.SQLITE3::SQL = "CREATE TABLE IF NOT EXISTS \"schema_migrations\" (\n    \"version\" BIGINT PRIMARY KEY,\n    \"applied_at\" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMES$
        DBD.SQLITE3::STORE = T
 1: (MITO.UTIL::CALL-WITH-PREPARED-QUERY #<DBD.SQLITE3:DBD-SQLITE3-CONNECTION {1002B4F4B3}> "CREATE TABLE IF NOT EXISTS \"schema_migrations\" ( ..)
 2: ((:METHOD MITO.DB:EXECUTE-SQL (STRING)) "CREATE TABLE IF NOT EXISTS \"schema_migrations\" ( ..) [fast-method]
      Locals:
        MITO.DB::BINDS = (0)
        MITO.DB::SQL = "CREATE TABLE IF NOT EXISTS \"schema_migrations\" (\n    \"version\" BIGINT PRIMARY KEY,\n    \"applied_at\" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP$
 3: (MITO.MIGRATION.VERSIONS::INITIALIZE-MIGRATIONS-TABLE)
 4: (MITO.MIGRATION.VERSIONS:CURRENT-MIGRATION-VERSION)
 5: (MITO.MIGRATION.VERSIONS:MIGRATE #P"/tmp/db/" :DRY-RUN NIL :FORCE NIL)

But if I create table manually:

CREATE TABLE IF NOT EXISTS "schema_migrations" (
    "version" BIGINT PRIMARY KEY,
    "applied_at" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "dirty" BOOLEAN NOT NULL DEFAULT 0
);

then I'm able to generate and apply migrations and mito:create-dao works as well.

I'm using Mito from Ultralisp.org, version built at 2024-11-18 04:32:46, which corresponds to this commit (latest for the moment when this issue was created).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant