Commit graph

8 commits

Author SHA1 Message Date
Nurahmadie
76ed21c40f Cleanup some leftover
Don't have to import mattn/go-sqlite3 at pkg/database/migrate/sqlite.go
Remove unused DriverFunction declaration at migrate.go
2014-03-10 11:30:39 +07:00
Nurahmadie
81cf496811 Refactor migration.
Add `ChangeColumn`, `AddIndex`, `DropIndex` method to
Operation interface.
2014-03-10 07:08:58 +07:00
Nurahmadie
51519b62dd Actually use --driver option to set database driver for drone.
This includes refactoring database setup, and migration system.

Remove setupDatabase from main and use `Init` method from database
package.

At database package, defines Init method which actually initiate
database with options given from comand line flag. I think `--path`
wont be used anywhere so I plan to remove it later.

Both meddler and migration initiated here, then we call `Set` method
to setup all the tables, etc. Here I think I want to separate database
schema and turn it into migration script instead, later maybe.

At migration package I made some tweak to `Operation` interface.
Realized that it's ludicrous to let migration driver re-implement `Exec`
and `Query`, I made migration script to receive The whole
migrationDriver struct which contains both Operation implementor, and
the Tx itself. This made possible thanks to Go struct being able to
promote its member, now our migration is more transparent.

There's also stub implementation for bot mysql and postgresql, will
implement this really soon.
2014-03-08 12:19:28 +07:00
Brad Rydzewski
a200c7a0a2 altered migration to set default github domain and url 2014-02-17 23:08:06 -07:00
Nurahmadie
8ce87f0d2c More tests for alter columns migration
Also change the way we handle columns rename migration.
SQLite restrict column addition not to have PRIMARY KEY and/or
UNIQUE attribute, so we have to change from:

add new column -> migrate data from old column to new column ->
rename old table -> create new table with old columns removed ->
migrate data from old table to the new table -> drop old table

to directly:
rename old table -> create new table with renamed columns ->
migrate data from old table to the new table -> drop old table
2014-02-16 00:56:17 +07:00
Nurahmadie
4465b2654d Fix migration step not checked against current version.
Add tests for DropColumns.
2014-02-15 22:17:22 +07:00
Nurahmadie
54a9544044 Integrate MigrationDriver to migrate.go 2014-02-15 20:16:54 +07:00
Brad Rydzewski
8d135d7b22 package for database migrations 2014-02-10 03:03:22 -07:00