From ba2b119c67cd36be9ba9404c8df121668bcc079f Mon Sep 17 00:00:00 2001 From: luoji Date: Wed, 12 Feb 2020 15:15:56 +0800 Subject: [PATCH 1/3] fix ORA-00922 issue - missing or invalid option in database oracle Signed-off-by: luoji --- migrate.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/migrate.go b/migrate.go index fae3b4c5..41585811 100644 --- a/migrate.go +++ b/migrate.go @@ -457,6 +457,10 @@ func (ms MigrationSet) ExecMax(db *sql.DB, dialect string, m MigrationSource, di } for _, stmt := range migration.Queries { + // remove the semicolon from stmt, fix ORA-00922 issue in database oracle + stmt = strings.TrimSuffix(stmt, "\n") + stmt = strings.TrimSuffix(stmt, " ") + stmt = strings.TrimSuffix(stmt, ";") if _, err := executor.Exec(stmt); err != nil { if trans, ok := executor.(*gorp.Transaction); ok { _ = trans.Rollback() From 6a356c357bc371fd89c50eede18431f3a1e1c3eb Mon Sep 17 00:00:00 2001 From: luoji Date: Wed, 12 Feb 2020 15:58:33 +0800 Subject: [PATCH 2/3] support for oracle in command line pargarm Signed-off-by: luoji --- README.md | 19 +++++++++++++++++++ sql-migrate/oracle.go | 12 ++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 sql-migrate/oracle.go diff --git a/README.md b/README.md index c87ee09a..45ff8f84 100644 --- a/README.md +++ b/README.md @@ -130,6 +130,25 @@ production: See [here](https://github.com/go-sql-driver/mysql#parsetime) for more information. +### Oracle +Oracle Driver is [oci8](https://github.com/mattn/go-oci8), it is not pure golang code and rely on Oracle Office Client([Instant Client](https://www.oracle.com/technetwork/database/database-technologies/instant-client/downloads/index.html)), more detail information is [oci8 repo](https://github.com/mattn/go-oci8). + +**Installation specified sql-migrate** + +To install the library and command line program, use the following: + +```bash +go get -tags oracle -v github.com/rubenv/sql-migrate/... +``` + +```yml +development: + dialect: oci8 + datasource: user/password@localhost:1521/sid + dir: migrations/oracle + table: migrations +``` + ### As a library Import sql-migrate into your application: diff --git a/sql-migrate/oracle.go b/sql-migrate/oracle.go new file mode 100644 index 00000000..d12e4a78 --- /dev/null +++ b/sql-migrate/oracle.go @@ -0,0 +1,12 @@ +// +build oracle + +package main + +import ( + _ "github.com/mattn/go-oci8" + migrate "github.com/rubenv/sql-migrate" +) + +func init() { + dialects["oci8"] = migrate.OracleDialect{} +} From 6817a62f734ba61413fc000e115be6cd3b00e3c6 Mon Sep 17 00:00:00 2001 From: Ruben Vermeersch Date: Wed, 12 Feb 2020 09:14:46 +0100 Subject: [PATCH 3/3] Slightly improve title --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 45ff8f84..856784f6 100644 --- a/README.md +++ b/README.md @@ -133,7 +133,7 @@ See [here](https://github.com/go-sql-driver/mysql#parsetime) for more informatio ### Oracle Oracle Driver is [oci8](https://github.com/mattn/go-oci8), it is not pure golang code and rely on Oracle Office Client([Instant Client](https://www.oracle.com/technetwork/database/database-technologies/instant-client/downloads/index.html)), more detail information is [oci8 repo](https://github.com/mattn/go-oci8). -**Installation specified sql-migrate** +#### Install with Oracle support To install the library and command line program, use the following: