Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

#### Install with Oracle support

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:
Expand Down
4 changes: 4 additions & 0 deletions migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
12 changes: 12 additions & 0 deletions sql-migrate/oracle.go
Original file line number Diff line number Diff line change
@@ -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{}
}