added plugins subpackage and added basic support for js migrations

This commit is contained in:
Gani Georgiev
2022-11-26 09:05:52 +02:00
parent 3e1a19685b
commit d8963c6fc3
19 changed files with 889 additions and 120 deletions

View File

@@ -111,19 +111,19 @@ func (r *Runner) Up() ([]string, error) {
err := r.db.Transactional(func(tx *dbx.Tx) error {
for _, m := range r.migrationsList.Items() {
// skip applied
if r.isMigrationApplied(tx, m.file) {
if r.isMigrationApplied(tx, m.File) {
continue
}
if err := m.up(tx); err != nil {
return fmt.Errorf("Failed to apply migration %s: %w", m.file, err)
if err := m.Up(tx); err != nil {
return fmt.Errorf("Failed to apply migration %s: %w", m.File, err)
}
if err := r.saveAppliedMigration(tx, m.file); err != nil {
return fmt.Errorf("Failed to save applied migration info for %s: %w", m.file, err)
if err := r.saveAppliedMigration(tx, m.File); err != nil {
return fmt.Errorf("Failed to save applied migration info for %s: %w", m.File, err)
}
applied = append(applied, m.file)
applied = append(applied, m.File)
}
return nil
@@ -146,7 +146,7 @@ func (r *Runner) Down(toRevertCount int) ([]string, error) {
m := r.migrationsList.Item(i)
// skip unapplied
if !r.isMigrationApplied(tx, m.file) {
if !r.isMigrationApplied(tx, m.File) {
continue
}
@@ -155,15 +155,15 @@ func (r *Runner) Down(toRevertCount int) ([]string, error) {
break
}
if err := m.down(tx); err != nil {
return fmt.Errorf("Failed to revert migration %s: %w", m.file, err)
if err := m.Down(tx); err != nil {
return fmt.Errorf("Failed to revert migration %s: %w", m.File, err)
}
if err := r.saveRevertedMigration(tx, m.file); err != nil {
return fmt.Errorf("Failed to save reverted migration info for %s: %w", m.file, err)
if err := r.saveRevertedMigration(tx, m.File); err != nil {
return fmt.Errorf("Failed to save reverted migration info for %s: %w", m.File, err)
}
reverted = append(reverted, m.file)
reverted = append(reverted, m.File)
}
return nil