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]>
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.
* 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]>
* 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
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.
* 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
* 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
* 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]>
* 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]>
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.
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
* 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