feat(05-01): restructure fonoteka plugins into Winter directories
- Move models, classes, controllers, middleware, and updates into subpackages - Add self-registering models/updates/classes registries so later plans add files - Keep the genres route and shipped migration SQL unchanged
This commit is contained in:
33
updates/00_base.go
Normal file
33
updates/00_base.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package updates
|
||||
|
||||
import (
|
||||
"github.com/go-gormigrate/gormigrate/v2"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Folds PHP updates/v1.0.1/create_users_table.php and
|
||||
// updates/v3.2.1/add_must_change_password_to_users.php into the minimal
|
||||
// columns the first vertical slice reads.
|
||||
var migrations = []*gormigrate.Migration{
|
||||
{
|
||||
ID: "202609170001_create_users",
|
||||
Migrate: func(tx *gorm.DB) error {
|
||||
return tx.Exec(`
|
||||
CREATE TABLE users (
|
||||
id SERIAL PRIMARY KEY,
|
||||
email TEXT NOT NULL UNIQUE,
|
||||
password TEXT NOT NULL DEFAULT '',
|
||||
must_change_password BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
)`).Error
|
||||
},
|
||||
Rollback: func(tx *gorm.DB) error {
|
||||
return tx.Exec(`DROP TABLE IF EXISTS users`).Error
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
Register(migrations...)
|
||||
}
|
||||
15
updates/registry.go
Normal file
15
updates/registry.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package updates
|
||||
|
||||
import "github.com/go-gormigrate/gormigrate/v2"
|
||||
|
||||
var all []*gormigrate.Migration
|
||||
|
||||
// Register appends gormigrate steps so later plans add files without editing plugin.go.
|
||||
func Register(ms ...*gormigrate.Migration) {
|
||||
all = append(all, ms...)
|
||||
}
|
||||
|
||||
// All returns every migration registered by this plugin's updates package.
|
||||
func All() []*gormigrate.Migration {
|
||||
return all
|
||||
}
|
||||
Reference in New Issue
Block a user