mirror of
https://github.com/tenrok/event-scheduling.git
synced 2026-06-20 20:00:38 +03:00
refactor: added seed db to db.go file
This commit is contained in:
@@ -18,3 +18,14 @@ func initDBConnection() *sql.DB {
|
|||||||
|
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func seedDB(db *sql.DB) error {
|
||||||
|
log.Print("💾 Seeding database with table...")
|
||||||
|
_, err := db.Exec(`
|
||||||
|
CREATE TABLE IF NOT EXISTS "public"."test" (
|
||||||
|
"id" integer NOT NULL,
|
||||||
|
"name" text NOT NULL
|
||||||
|
)
|
||||||
|
`)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|||||||
-17
@@ -1,17 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"database/sql"
|
|
||||||
"log"
|
|
||||||
)
|
|
||||||
|
|
||||||
func seedDB(db *sql.DB) error {
|
|
||||||
log.Print("💾 Seeding database with table...")
|
|
||||||
_, err := db.Exec(`
|
|
||||||
CREATE TABLE IF NOT EXISTS "public"."test" (
|
|
||||||
"id" integer NOT NULL,
|
|
||||||
"name" text NOT NULL
|
|
||||||
)
|
|
||||||
`)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user