Skip to content

Error running migrations: code: 1001 #1275

Open
@itschip

Description

@itschip

Describe the Bug
Whenever I try to run the migration through Go with the library in WSL, this error pops up:

Error running migrations: code: 1001, message: std::exception: std::exception in line 0: INSERT INTO schema_migrations (version, dirty, sequence) VALUES (?, ?, ?)

func RunClickhouseMigrations() {
	options := getClickhouseOptions()
	db := clickhouse.OpenDB(options)

	driver, err := clickhouseMigrate.WithInstance(db, &clickhouseMigrate.Config{
		MigrationsTableEngine: "MergeTree",
		MultiStatementEnabled: true,
	})
	if err != nil {
		fmt.Println("Error creating ClickHouse driver:", err)
		panic(err)
	}

	migrationsPath := filepath.Join(projectpath.GetRoot(), "store", "db", "migrations")
	fmt.Println("Migrations path:", migrationsPath)

	m, err := migrate.NewWithDatabaseInstance("file://"+migrationsPath, "db1", driver)
	if err != nil {
		fmt.Println("Error running migrations:", err)
		panic(err)
	}

	err = m.Up()
	if err != nil && err != migrate.ErrNoChange {
		fmt.Println("Error running migrations:", err)
		panic(err)
	}

	fmt.Println("Migrations completed successfully.")
}

It is an empty clickhouse database.

Steps to Reproduce
Steps to reproduce the behavior:

  1. Set up a new clickhouse server (bitnami/clickhouse:25.1.3)
  2. Create a migration and run it Up() with the golang-migrate lib
  3. See error: Error running migrations: code: 1001, message: std::exception: std::exception in line 0: INSERT INTO schema_migrations (version, dirty, sequence) VALUES (?, ?, ?)

Expected Behavior
The migration should go through

Migrate Version
v4.18.3

Loaded Source Drivers
file

Loaded Database Drivers
clickhouse

Go Version
go1.24.3 linux/amd64

Stacktrace
Please provide if available

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions