mirror of
https://github.com/ForFarmTeam/ForFarm.git
synced 2025-12-19 22:14:08 +01:00
fix: fix migration via args failed
This commit is contained in:
parent
856823d87d
commit
b9419287e7
@ -11,7 +11,7 @@ import (
|
|||||||
"github.com/pressly/goose/v3"
|
"github.com/pressly/goose/v3"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
migrations "github.com/forfarm/backend/internal"
|
"github.com/forfarm/backend/migrations"
|
||||||
)
|
)
|
||||||
|
|
||||||
func MigrateCmd(ctx context.Context, dbDriver, dbSource string) *cobra.Command {
|
func MigrateCmd(ctx context.Context, dbDriver, dbSource string) *cobra.Command {
|
||||||
@ -29,7 +29,7 @@ func MigrateCmd(ctx context.Context, dbDriver, dbSource string) *cobra.Command {
|
|||||||
|
|
||||||
goose.SetBaseFS(migrations.EmbedMigrations)
|
goose.SetBaseFS(migrations.EmbedMigrations)
|
||||||
|
|
||||||
if err := goose.UpContext(ctx, db, "migrations"); err != nil {
|
if err := goose.UpContext(ctx, db, "."); err != nil {
|
||||||
return fmt.Errorf("failed to run migrations: %w", err)
|
return fmt.Errorf("failed to run migrations: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
10
backend/makefile
Normal file
10
backend/makefile
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
.PHONY: live run migrate
|
||||||
|
|
||||||
|
live:
|
||||||
|
air -c .air.toml
|
||||||
|
|
||||||
|
run:
|
||||||
|
go run cmd/forfarm/main.go API
|
||||||
|
|
||||||
|
migrate:
|
||||||
|
go run cmd/forfarm/main.go migrate
|
||||||
@ -1,3 +1,4 @@
|
|||||||
|
-- +goose Up
|
||||||
CREATE TABLE users (
|
CREATE TABLE users (
|
||||||
id SERIAL PRIMARY KEY,
|
id SERIAL PRIMARY KEY,
|
||||||
uuid UUID NOT NULL,
|
uuid UUID NOT NULL,
|
||||||
@ -10,4 +11,4 @@ CREATE TABLE users (
|
|||||||
);
|
);
|
||||||
|
|
||||||
CREATE UNIQUE INDEX idx_users_uuid ON users(uuid);
|
CREATE UNIQUE INDEX idx_users_uuid ON users(uuid);
|
||||||
CREATE UNIQUE INDEX idx_users_username ON users(username);
|
CREATE UNIQUE INDEX idx_users_username ON users(username);
|
||||||
@ -4,5 +4,5 @@ import (
|
|||||||
"embed"
|
"embed"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed migrations/*.sql
|
//go:embed *.sql
|
||||||
var EmbedMigrations embed.FS
|
var EmbedMigrations embed.FS
|
||||||
Loading…
Reference in New Issue
Block a user