mirror of
https://github.com/therootcompany/golib.git
synced 2026-02-11 06:18:06 +00:00
feat(cmd/sql-migrate/v2): add mssql and sqlite3
This commit is contained in:
parent
0603b89613
commit
b04052211f
@ -38,6 +38,8 @@ const (
|
|||||||
sqlCommandPSQL = `psql "$PG_URL" -v ON_ERROR_STOP=on -A -t --file %s`
|
sqlCommandPSQL = `psql "$PG_URL" -v ON_ERROR_STOP=on -A -t --file %s`
|
||||||
sqlCommandMariaDB = `mariadb --defaults-extra-file="$MY_CNF" -s -N --raw < %s`
|
sqlCommandMariaDB = `mariadb --defaults-extra-file="$MY_CNF" -s -N --raw < %s`
|
||||||
sqlCommandMySQL = `mysql --defaults-extra-file="$MY_CNF" -s -N --raw < %s`
|
sqlCommandMySQL = `mysql --defaults-extra-file="$MY_CNF" -s -N --raw < %s`
|
||||||
|
sqlCommandSQLite3 = "sqlite3 \"$SQLITE_DB_FILE\" -bail -noheader -separator \"\t\" < %s"
|
||||||
|
sqlCommandMSSQL = "sqlcmd -S tcp:\"$MSSQL_HOST\" -U \"$MSSQL_USER\" -P \"$MSSQL_PASS\" -d \"$MSSQL_DBNAME\" -b -h-1 -W -s\"\t\" < %s"
|
||||||
LOG_QUERY_NAME = "_migrations.sql"
|
LOG_QUERY_NAME = "_migrations.sql"
|
||||||
M_MIGRATOR_NAME = "0001-01-01-01000_init-migrations"
|
M_MIGRATOR_NAME = "0001-01-01-01000_init-migrations"
|
||||||
M_MIGRATOR_UP_NAME = "0001-01-01-01000_init-migrations.up.sql"
|
M_MIGRATOR_UP_NAME = "0001-01-01-01000_init-migrations.up.sql"
|
||||||
@ -79,7 +81,7 @@ USAGE
|
|||||||
sql-migrate [-d sqldir] <command> [args]
|
sql-migrate [-d sqldir] <command> [args]
|
||||||
|
|
||||||
EXAMPLE
|
EXAMPLE
|
||||||
sql-migrate -d ./sql/migrations/ init --sql-command <psql|mariadb|mysql>
|
sql-migrate -d ./sql/migrations/ init --sql-command <psql|mariadb|mysql|sqlcmd|sqlite3>
|
||||||
sql-migrate -d ./sql/migrations/ create <kebab-case-description>
|
sql-migrate -d ./sql/migrations/ create <kebab-case-description>
|
||||||
sql-migrate -d ./sql/migrations/ status
|
sql-migrate -d ./sql/migrations/ status
|
||||||
sql-migrate -d ./sql/migrations/ up 99
|
sql-migrate -d ./sql/migrations/ up 99
|
||||||
@ -201,6 +203,10 @@ func main() {
|
|||||||
cfg.sqlCommand = sqlCommandMariaDB
|
cfg.sqlCommand = sqlCommandMariaDB
|
||||||
case "mysql", "my":
|
case "mysql", "my":
|
||||||
cfg.sqlCommand = sqlCommandMySQL
|
cfg.sqlCommand = sqlCommandMySQL
|
||||||
|
case "mssql", "sqlcmd":
|
||||||
|
cfg.sqlCommand = sqlCommandMSSQL
|
||||||
|
case "sqlite3", "sqlite":
|
||||||
|
cfg.sqlCommand = sqlCommandSQLite3
|
||||||
}
|
}
|
||||||
|
|
||||||
if !strings.HasSuffix(cfg.migrationsDir, "/") {
|
if !strings.HasSuffix(cfg.migrationsDir, "/") {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user