Compare commits
2 Commits
feature/sc
...
48072cd26e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
48072cd26e | ||
|
|
75867ba778 |
@@ -135,21 +135,13 @@ type migration struct {
|
|||||||
func (database *Database) runMigrations(
|
func (database *Database) runMigrations(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
) error {
|
) error {
|
||||||
bootstrap, err := SchemaFiles.ReadFile(
|
_, err := database.conn.ExecContext(ctx,
|
||||||
"schema/000.sql",
|
`CREATE TABLE IF NOT EXISTS schema_migrations (
|
||||||
)
|
version INTEGER PRIMARY KEY,
|
||||||
|
applied_at DATETIME DEFAULT CURRENT_TIMESTAMP)`)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf(
|
return fmt.Errorf(
|
||||||
"read bootstrap migration: %w", err,
|
"create schema_migrations: %w", err,
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = database.conn.ExecContext(
|
|
||||||
ctx, string(bootstrap),
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf(
|
|
||||||
"execute bootstrap migration: %w", err,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,11 +270,6 @@ func (database *Database) loadMigrations() (
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip bootstrap migration; it is executed separately.
|
|
||||||
if version == 0 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
content, readErr := SchemaFiles.ReadFile(
|
content, readErr := SchemaFiles.ReadFile(
|
||||||
"schema/" + entry.Name(),
|
"schema/" + entry.Name(),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
-- Bootstrap: create the schema_migrations table itself.
|
|
||||||
CREATE TABLE IF NOT EXISTS schema_migrations (
|
|
||||||
version INTEGER PRIMARY KEY,
|
|
||||||
applied_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
||||||
);
|
|
||||||
INSERT OR IGNORE INTO schema_migrations (version) VALUES (0);
|
|
||||||
Reference in New Issue
Block a user