Removes internal directory
This commit is contained in:
parent
c65e239b68
commit
5005186cd3
2 changed files with 0 additions and 46 deletions
|
|
@ -1,38 +0,0 @@
|
|||
package database
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"fmt"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
migrate "github.com/rubenv/sql-migrate"
|
||||
)
|
||||
|
||||
var DB *sqlx.DB
|
||||
|
||||
//go:embed migrations/*
|
||||
var dbMigrations embed.FS
|
||||
|
||||
func Connect(filename string) error {
|
||||
DB, err := sqlx.Open("sqlite3", filename)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
migrations := migrate.EmbedFileSystemMigrationSource{
|
||||
FileSystem: dbMigrations,
|
||||
Root: "migrations",
|
||||
}
|
||||
|
||||
n, err := migrate.Exec(DB.DB, "sqlite3", migrations, migrate.Up)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("Applied %d migrations - Database is ready!\n", n)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
-- +migrate Up
|
||||
CREATE table users (
|
||||
id INTEGER PRIMARY KEY,
|
||||
name text NOT NULL
|
||||
);
|
||||
|
||||
-- +migrate Down
|
||||
DROP TABLE users;
|
||||
Loading…
Add table
Add a link
Reference in a new issue