46 Commits
Author SHA1 Message Date
zeekayandHanzo Dev bfc4b67c2f refactor(datastore): back the datastore migration driver with native hanzo-ds/go, drop clickhouse-go
The datastore:// migration driver is now a self-contained golang-migrate
database.Driver that opens through github.com/hanzo-ds/go (the native
ClickHouse-wire driver registered as the database/sql name "datastore").
The ClickHouse-specific migration logic (multi-statement exec,
schema_migrations DDL, cluster/engine config, Version/SetVersion/Drop/Lock)
is ported directly into database/datastore, so it no longer embeds or
imports the upstream database/clickhouse driver or
github.com/ClickHouse/clickhouse-go.

- Delete database/clickhouse (driver + test + examples) and
  internal/cli/build_clickhouse.go.
- internal/cli/build_datastore.go drops the clickhouse-go blank import.
- go.mod: drop github.com/ClickHouse/clickhouse-go, add
  github.com/hanzo-ds/go v1.0.1; tidy. Zero clickhouse-go in go.mod,
  go.sum, and the module/dependency graph.
- Port the driver test + example migrations under database/datastore
  (integration test requires a live datastore/clickhouse-wire backend).
- Update README, release workflow build tags, bug report template.

Co-authored-by: Hanzo Dev <[email protected]>
2026-07-18 18:40:56 -07:00
zeekay 0f12524bc1 Add datastore database driver for Hanzo Datastore
Registers "datastore://" as a URL scheme that delegates to the
ClickHouse driver. This allows golang-migrate to natively connect
to Hanzo Datastore instances without URL rewriting in scripts.
2026-03-03 09:15:21 -08:00
e40cf943ca ci: update golangci-lint to v2 (#1341)
* ci: update golangci-lint to v2

update method:
```
golangci-lint migrate
golangci-lint run --fix
```

and fix the last ones manually

* Apply suggestion from @Copilot

* fix tests

---------

Co-authored-by: Hanzo Dev <[email protected]>
2025-12-14 15:14:46 -08:00
Oleksandr Redko fca627ee8e Remove redundant build tags 2025-04-17 23:57:28 +03:00
Shion Ichikawa bab85e01ff 🚨 golangci-lint: fix for errcheck lint errors 2024-06-05 23:40:12 +09:00
Erik Swenson 16ed492fcf feature: add rqlite support 2023-11-27 17:05:24 -07:00
Eli TreuherzandGitHub 419db081d0 Add driver for pgx v5 (#848)
* Add driver for pgx v5

Fixes #827

- Move existing driver into database/pgx/v4
- Make exported items into database/pgx into links to database/pgx/v4,
  marked as Deprecated
- Remove most tests in database/pgx, leaving a couple of e2e tests
  behind to help ensure backwards compatibility.
- Mark defunct ErrDatabaseDirty as Deprecated - no code returns it
- Bump pgx/v4 dependency
- Add test runs for newer Postgres versions

* Tweak pgx tags and registration strings

* Tweak registration strings
2023-04-04 21:57:01 -07:00
Igor MorozovandGitHub a5da790073 Merge branch 'master' into feat/yugabyte-support 2022-08-24 09:44:44 +03:00
Abhinav Nair baec8ed6b6 Replace deprecated ioutil pkg with os & io
As of Go 1.16, the same functionality is now provided by package io or
package os, and those implementations should be preferred in new code.

So replacing all usage of ioutil pkg with io & os.
2022-06-26 16:57:29 +08:00
Igor Morozov 6972470e54 feat: add yugabyte support 2022-04-03 00:25:18 +03:00
Dale Hui 5ba9446324 Run gofmt on internal build dir 2021-11-23 16:30:29 -08:00
Andrew GillisandGitHub 4f26ec3bf2 Add support for modernc.org/sqlite (#555)
* Add support for modernc.org/sqlite

This is a CGo-free port of SQLite

* Remove sqlite from build target
2021-05-05 10:04:18 -07:00
Dale HuiandGitHub a719adec93 Merge pull request #522 from Juneezee/remove-all-from-drop
Move `-all` flag usage from `drop` to `down`
2021-03-13 21:36:01 -08:00
Dylan BargteilandGitHub 3d4a50190f Add pgx driver package (#517)
* replace lib/pq dependency with pgx in postgres driver

* fix pgx error handling

pgconn is a low-level library, and errors from queries flow through higher-level pgx library

* update postgres tests to use pgx driver and error reporting

* update quoteIdentifier implementation to match lib/pq

* move changes for pgx support into new driver package

* add pgx driver to CLI

* restore examples used in testing for pgx driver

* replace postgres driver name with pgx in DSN in tests and docs

* consolidate connection string formatting in pgx testing

* lock pgx package at v4

Prior to v4, pgx did not support go modules. Version locking the import is the safest way to ensure we get the (as of now) latest version of the module. Additionally v4 implements some breaking changes to connection and error handling, which are also addressed in this commit.

* update parsed URL scheme instead of using string operation

* add pgx for builds using make

* add pgx to top level docs

* remove autogenerated TOC
2021-03-13 21:29:10 -08:00
Eng Zer Jun a912e56c08 fix: move -all flag usage from drop to down
The `-all` flag usage should be used in `down` only, not `drop`.

Signed-off-by: Eng Zer Jun <[email protected]>
2021-03-13 15:22:09 +08:00
John Tzikas 4e91d7a58c Allow the abillity to pass timezone when generating migration files 2021-02-23 20:20:14 +02:00
Dale Hui a4540ce0db Use flagset's NArg() and Arg() methods instead of global flag NArg() and Arg() for sub-commands
Fixes: https://github.com/golang-migrate/migrate/issues/467
2020-11-04 23:37:05 -08:00
Yannick HeinrichandGitHub 212c7b590b Add help statement for cli (#460)
* Add help statement for cli

Refers to #372

* Make constant for argument

* Create a flagset for each command

* Factor error handling

* Factor flagset creation

* fix: Typo and bad behaviour

* Fix lint error

* Fix according to the comments

* Fix according to the comments
2020-11-03 14:54:12 -08:00
EvanandGitHub 9088a7a310 Document drop -f in migrate -help (#459)
* Document drop -f in migrate -help

* Document drop -f in migrate -help 2
2020-10-17 01:44:43 -07:00
955d4f5158 Add Bitbucket Cloud Support as source (#450)
* Added bitbucket cloud support as source for migration

* added test

* address PR Comments

* Add entry in README.md; update go.mod and go.sum

Co-authored-by: abhigupta91 <[email protected]>
2020-09-28 22:08:20 -07:00
Andreas Linz 9ca5b841b6 Add build file for sqlcipher 2020-09-02 20:44:52 +02:00
Abhinav Kumar 6f1b6f8857 Adding support for schema management in snowflake 2020-06-03 13:55:24 +05:30
Shogo IwanoandGitHub 185a1a4e52 Add -f option to drop command (#390)
* Add -y option to drop command

* Replace -y -> -f

* Update -f help text of drop command
2020-05-18 10:42:14 -07:00
Nicholas Soper a22adb79f9 Give positive feedback when dropping schema 2020-03-18 09:02:00 +00:00
Nicholas Soper 3097d195e2 Prompt before dropping the entire database 2020-03-17 17:37:27 +00:00
48f87f94f0 Improved migration creation + Windows fix (#352)
* CLI: Improve migration creation.

* Validates migration version on creation, to avoid creation of duplicated versions
* Uses `os.OpenFile` with `O_CREATE|O_EXCL` to create files to avoid file collisions
* Uses `filepath.Join` to concatenate paths, making `cleanPath()` not necessary
* Prints generated filenames
* Fixes #238
* Supersedes #250

* CLI: change `createCmd` to return error and accept `print` parameter

* feat: print out an abs path

Better for Windows OS when specify -dir as /subdir, user will see C:/subdir/0001_name.up.sql rather than /subdir/0001_name.up.sql

* test: fixed abs path test fail for OS Windows

abs path tests fails because filepath.IsAbs() treats `/subdir` path as invalid abs path at windows when drive letter is not present

* feat: print absolute path for created files

Better for Windows OS systems where `/path` can be interpreted in different ways depending on working dir

* test: corrected tests for OS Windows

OS Windows has different interpretation of `/path`, it depends on working dir.
If working dir D:\test it interprets `/path` as `D:\path`

* test: fixed `dir invalid` test

Linux OS has less restriction on a filepath than Windows, so path invalid in windows is perfectly valid for Linux. The only invalid dir name in Linux is one ending with null string terminator (\000)

* refac(cli): *Cmd() now returns an error and not uses log.fatalErr(err)

* docs: added godoc, migarate usage updated

* refac(cli): code refactored

* refac: removed unnecessary path covert

* docs: comment added

* test: fixed code review issue, noErrorExpected var removed

https://github.com/golang-migrate/migrate/pull/352#discussion_r389409789

* docs: fixed godoc

Co-authored-by: Kiyoshi '13k' Murata <[email protected]>
2020-03-10 16:59:11 -07:00
Mantas VidutisandDale Hui 7692e36073 Allow for multistatement migrations in Neo4j (#328)
* allow for multistatement migrations

* multi statement option

* parse bool and package const

* default false multi, change package var to byte[]
2020-01-22 23:59:32 -08:00
Mantas VidutisandDale Hui 7989e23e22 Neo4J Support (#320)
* initial pass

* new cli build file

* add ready function for docker start

* lowercase j

* explicit return

* test migration

* undo dockerfile change

* neo4j in dockerfile

* remove auth from url once transferred to auth token

* assorted review notes

* initial docs attempt

* unlock behavior more in line with lock behavior

* consistent naming

* linting

* seabolt in travis ci

* stdlib logger

* install seabolt as sudo

* enabled cgo

* correct version #

* remove neo4j todo

* named return values for errors

* review notes

* add libssl for alpine

* updates for review
2020-01-14 21:59:22 -08:00
Iman Tumorang efdfd9471a fix(dependency): resolve clickhouse dependency breaking changes 2019-11-21 10:18:48 +08:00
Yohan Robert c68bbcb826 Add documentation for exit 2 2019-08-09 15:15:29 +02:00
Yohan Robert dd5c148a31 Change exit status to 2 on command error
The default exit status when a command cannot be found was 0.
This can cause migrate to fail "silently" in case of typos.
Given that providing an invalid flag causes the program to exit
with a exit status set to 2, the default exit status was also set to 2.
2019-08-07 20:13:16 +02:00
Andrew Klotz 2fe7f0e964 migrate down less destructive
default behaviour for down is to apply all down migrations, which is
comparable to dropping a database - and usually not the desired default
action

proposed changes:

 * `down` prompts for a confirm `y` before applying all down migrations, defaulting to doing nothing
 * `down --all` does the current behaviour, applying all down migrations
 * `down N` is unchanged

 * `down N --all` errors
 * `down --all N` errors
2019-06-26 00:00:54 -04:00
Dale Hui ccf40b4518 Properly clean/normalize user specified directory for create command
Addresses: https://github.com/golang-migrate/migrate/issues/238
2019-06-20 21:35:51 -07:00
Kasparas GaldikasandDale Hui 57af81c94a Github Enterprise support (#234)
* exported Github struct fields and ReadDirectory method

* github ee implementation, tests and docs

* build fixes

* Github Enterprise API endpoint based on docs

* addressing PR comments

* code review

* make linter happy

* parseBool() takes fallback

* pr comments

* tweaks to Config{}
2019-06-16 12:48:01 -07:00
Thomas Lokshall 6a24d9df75 rename mssql driver to sqlserver 2019-05-24 15:16:12 +02:00
nathan-c 6dd94f09dd fix mssql build flag 2019-05-19 14:47:09 +01:00
nathan-c f43029829e Merge remote-tracking branch 'evosure/mssql' 2019-05-18 14:39:55 +01:00
Kirill MuratovandDale Hui 8afa5fa221 Enabled maligned, staticcheck and errcheck linters (#206)
* Enabled maligned check

* Enabled staticcheck

* Fixes for golint

* Enabled errcheck linter

* Added fixes for error check

* Added errcheck for tests

* Fixed test

* Increased golangci-lint deadline for travis

* Increased golangci-lint deadline for travis

* Decreased golangci-lint deadline for travis

* Revert for backward compatibility

* Using log.Println() instead of fmt.Println()

* Handling os.RemoveAll() errors

* Using t.Error(error) instead of t.Errorf("%v", err)

* Using t.Fatal(error) instead of t.Fatalf("%v", err)

* Using fmt.Sprint(sum) instead of t.Srintf("%v", sum)

* Refactoring

* Revert for backward compatibility

* Revert

* go mod tidy

* Added error logging

* Added error logging

* Added error handling

* Added error handling

* Added error logging

* Fix error logging

* Added error handling

* Fix

* Added logging for migr.Buffer()

* Fixes

* Firebird test disabled

* Fixed nolint comment

* Updated firebird docker image version

* Disabled test for firebird 2.5

* Fixed // nolint
2019-04-26 15:47:16 -07:00
Kirill Muratov 28a0b0865d Fixes for unused linter 2019-03-22 22:08:29 +03:00
Kirill Muratov 25f12d2494 Fixes for gosimple linter 2019-03-22 22:02:08 +03:00
Kirill MuratovandDale Hui fea2fd1741 Added Firebird support (#191)
* Added Firebird support

* Fixed typo

* Refactoring

* Schema migrations table name don't have to be upper case

* Fixed readme

* Added Firebird 2.5 support

* Removed SchemaName

* Refactoring
2019-03-21 01:51:49 -07:00
Cyrille HemidyandDale Hui 9be1db5f5d Fmt (#189)
* fix gofmt -s

* fix gofmt -s + fix mispelling
2019-03-13 12:15:21 -07:00
Bence PatyiandDale Hui fffa3e93dd Gitlab source (#184)
* New Gitlab source

* fix: use net package to build url string

* add: gitlab source to Makefile and Dockerfile
2019-03-10 18:38:23 -07:00
Brian Wigginton 587618fdaf initial mssql support 2019-02-15 16:12:57 -06:00
DBobrov 65c009a98f added mongodb driver 2019-01-01 11:14:27 +03:00
Viacheslav Poturaev a2cbe590d2 Copy cli main package under migrate directory, keep deprecated original main package for backwards compatibility, fixes #70 2018-11-21 09:01:35 +01:00