this repo has no description
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

move migrations

+26 -4
+13 -4
db/migrations.go
··· 2 2 3 3 import ( 4 4 "database/sql" 5 + "embed" 6 + "log" 5 7 ) 8 + 9 + //go:embed migrations/0001.sql 10 + var migration0001 embed.FS 6 11 7 12 func RunMigrations(db *sql.DB) error { 8 13 // Load the cr-sqlite extension ··· 11 16 // return fmt.Errorf("failed to load cr-sqlite extension: %w", err) 12 17 // } 13 18 19 + // Read the embedded SQL file 20 + sqlData, err := migration0001.ReadFile("migrations/0001.sql") 21 + if err != nil { 22 + log.Fatalf("Failed to read embedded SQL file: %v", err) 23 + } 24 + sqlQuery := string(sqlData) 25 + 14 26 // Create the todos table and initialize it as a CRDT 15 - _, err := db.Exec(` 16 - CREATE TABLE IF NOT EXISTS todos (id blob PRIMARY KEY NOT NULL, content TEXT, completed INTEGER NOT NULL DEFAULT 0); 17 - SELECT crsql_as_crr('todos'); 18 - `) 27 + _, err = db.Exec(sqlQuery) 19 28 if err != nil { 20 29 return err 21 30 }
+13
db/migrations/0001.sql
··· 1 + CREATE TABLE IF NOT EXISTS todos 2 + ( 3 + id blob PRIMARY KEY NOT NULL, 4 + description text, 5 + project text, 6 + tags text, 7 + due text, 8 + wait text, 9 + priority text, 10 + urgency real, 11 + completed integer NOT NULL DEFAULT 0 12 + ); 13 + SELECT crsql_as_crr('todos');