mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Add triggers table via migration (#1088)
* Add triggers table via migration
This commit is contained in:
38
api/datastore/sql/migrations/17_add_triggers.go
Normal file
38
api/datastore/sql/migrations/17_add_triggers.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/fnproject/fn/api/datastore/sql/migratex"
|
||||
"github.com/jmoiron/sqlx"
|
||||
)
|
||||
|
||||
func up17(ctx context.Context, tx *sqlx.Tx) error {
|
||||
createQuery := `CREATE TABLE IF NOT EXISTS triggers (
|
||||
id varchar(256) NOT NULL PRIMARY KEY,
|
||||
name varchar(256) NOT NULL,
|
||||
app_id varchar(256) NOT NULL,
|
||||
fn_id varchar(256) NOT NULL,
|
||||
created_at varchar(256) NOT NULL,
|
||||
updated_at varchar(256) NOT NULL,
|
||||
type varchar(256) NOT NULL,
|
||||
source varchar(256) NOT NULL,
|
||||
annotations text NOT NULL,
|
||||
CONSTRAINT name_app_id_fn_id_unique UNIQUE (app_id, fn_id, name)
|
||||
);`
|
||||
_, err := tx.ExecContext(ctx, createQuery)
|
||||
return err
|
||||
}
|
||||
|
||||
func down17(ctx context.Context, tx *sqlx.Tx) error {
|
||||
_, err := tx.ExecContext(ctx, "DROP TABLE triggers;")
|
||||
return err
|
||||
}
|
||||
|
||||
func init() {
|
||||
Migrations = append(Migrations, &migratex.MigFields{
|
||||
VersionFunc: vfunc(17),
|
||||
UpFunc: up17,
|
||||
DownFunc: down17,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user