mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-05 03:17:50 +08:00
store: createTable -> initTable
This commit is contained in:
parent
c6bcb714c1
commit
2468aece8d
|
@ -10,7 +10,7 @@ import (
|
|||
var ErrNoMatchingCmd = errors.New("no matching command line")
|
||||
|
||||
func init() {
|
||||
createTable["cmd"] = `create table if not exists cmd (content text)`
|
||||
initTable["cmd"] = `create table if not exists cmd (content text)`
|
||||
}
|
||||
|
||||
// NextCmdSeq returns the next sequence number of the command history.
|
||||
|
|
|
@ -13,7 +13,7 @@ const (
|
|||
)
|
||||
|
||||
func init() {
|
||||
createTable["dir"] = `create table if not exists dir (path text unique primary key, score real default 0)`
|
||||
initTable["dir"] = `create table if not exists dir (path text unique primary key, score real default 0)`
|
||||
}
|
||||
|
||||
// AddDir adds a directory to the directory history.
|
||||
|
|
|
@ -14,7 +14,7 @@ type Store struct {
|
|||
db *sql.DB
|
||||
}
|
||||
|
||||
var createTable = map[string]string{}
|
||||
var initTable = map[string]string{}
|
||||
|
||||
// DefaultDB returns the default database for storage.
|
||||
func DefaultDB(dataDir string) (*sql.DB, error) {
|
||||
|
@ -37,10 +37,10 @@ func NewStore(dataDir string) (*Store, error) {
|
|||
func NewStoreDB(db *sql.DB) (*Store, error) {
|
||||
st := &Store{db}
|
||||
|
||||
for t, q := range createTable {
|
||||
for t, q := range initTable {
|
||||
_, err := db.Exec(q)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create table %s: %v", t, q)
|
||||
return nil, fmt.Errorf("failed to initialize table %s: %v", t, q)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user