package migrate

import (
	"testing"

	"github.com/stretchr/testify/require"
	"github.com/tidbcloud/dataflow-service/app/repo"
)

func TestInitSchema(t *testing.T) {
	db, err := repo.GetFakeDB()
	require.Nil(t, err)
	db.DisableForeignKeyConstraintWhenMigrating = true
	// the fake DB already migrate the schema,
	// here we create a new database to test the initDataflowDB
	db = db.Exec("create database init_schema_test").
		Exec("use init_schema_test")
	// test migration works when the database is empty
	require.Nil(t, initDataflowDB(db))
}
