|
|
|
@ -13,8 +13,8 @@ import (
|
|
|
|
|
var __version = 1
|
|
|
|
|
|
|
|
|
|
type DbCtx struct {
|
|
|
|
|
db *sql.DB
|
|
|
|
|
version int
|
|
|
|
|
Db *sql.DB
|
|
|
|
|
Version int
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func initVersion(tx *sql.Tx) (int, error) {
|
|
|
|
@ -40,19 +40,16 @@ func initVersion(tx *sql.Tx) (int, error) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func migration0(tx *sql.Tx) error {
|
|
|
|
|
// Optionally add the version table
|
|
|
|
|
if _, err := tx.Exec(`
|
|
|
|
|
create table if not exists eng_log_version (id integer not null);
|
|
|
|
|
create table if not exists diary_log (
|
|
|
|
|
id integer not null primary key,
|
|
|
|
|
title text,
|
|
|
|
|
created_at int not null default (strftime('%s','now')),
|
|
|
|
|
version int not null default 0
|
|
|
|
|
)
|
|
|
|
|
`); err != nil {
|
|
|
|
|
tx.Rollback()
|
|
|
|
|
return fmt.Errorf("Could not create eng_log_version. %w", err)
|
|
|
|
|
}
|
|
|
|
|
// Optionally add the log table
|
|
|
|
|
if _, err := tx.Exec(`
|
|
|
|
|
create table if not exists log (id integer not null primary key, title string)
|
|
|
|
|
`); err != nil {
|
|
|
|
|
tx.Rollback()
|
|
|
|
|
return fmt.Errorf("Could not create log. %w", err)
|
|
|
|
|
return fmt.Errorf("Could not create diary_log. %w", err)
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|