-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from josephspurrier/separate-mysql
Separate mysql and close a few issues
- Loading branch information
Showing
20 changed files
with
826 additions
and
313 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
rove | ||
rove.exe | ||
rove |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package rove_test | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/josephspurrier/rove" | ||
"github.com/josephspurrier/rove/pkg/database" | ||
) | ||
|
||
func Example() { | ||
var changesets = ` | ||
--changeset josephspurrier:1 | ||
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO'; | ||
CREATE TABLE user_status ( | ||
id TINYINT(1) UNSIGNED NOT NULL AUTO_INCREMENT, | ||
status VARCHAR(25) NOT NULL, | ||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | ||
deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, | ||
PRIMARY KEY (id) | ||
); | ||
--rollback DROP TABLE user_status; | ||
--changeset josephspurrier:2 | ||
INSERT INTO user_status (id, status, created_at, updated_at, deleted) VALUES | ||
(1, 'active', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 0), | ||
(2, 'inactive', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 0); | ||
--rollback TRUNCATE TABLE user_status;` | ||
|
||
// Create a new MySQL database object. | ||
db, err := database.NewMySQL(&database.Connection{ | ||
Hostname: "127.0.0.1", | ||
Username: "root", | ||
Password: "password", | ||
Database: "main", | ||
Port: 3306, | ||
Parameter: "collation=utf8mb4_unicode_ci&parseTime=true", | ||
}) | ||
if err != nil { | ||
log.Fatalln(err) | ||
} | ||
|
||
// Perform all migrations against the database. | ||
r := rove.NewChangesetMigration(db, changesets) | ||
r.Verbose = true | ||
err = r.Migrate(0) | ||
} |
Oops, something went wrong.