mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-02 22:56:30 +00:00
51519b62dd
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.
23 lines
444 B
Go
23 lines
444 B
Go
package migrate
|
|
|
|
type Rev1 struct{}
|
|
|
|
var RenamePrivelegedToPrivileged = &Rev1{}
|
|
|
|
func (r *Rev1) Revision() int64 {
|
|
return 201402200603
|
|
}
|
|
|
|
func (r *Rev1) Up(mg *MigrationDriver) error {
|
|
_, err := mg.RenameColumns("repos", map[string]string{
|
|
"priveleged": "privileged",
|
|
})
|
|
return err
|
|
}
|
|
|
|
func (r *Rev1) Down(mg *MigrationDriver) error {
|
|
_, err := mg.RenameColumns("repos", map[string]string{
|
|
"privileged": "priveleged",
|
|
})
|
|
return err
|
|
}
|