mirror of
https://github.com/aljazceru/khatru.git
synced 2025-12-24 00:34:24 +01:00
migrate off of main nostr repository.
This commit is contained in:
31
sqlite.go
Normal file
31
sqlite.go
Normal file
@@ -0,0 +1,31 @@
|
||||
// +build !full
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/jmoiron/sqlx"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
)
|
||||
|
||||
func initDB() (*sqlx.DB, error) {
|
||||
db, err := sqlx.Connect("sqlite3", s.SQLiteDatabase)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_, err = db.Exec(`
|
||||
CREATE TABLE event (
|
||||
id text NOT NULL,
|
||||
pubkey text NOT NULL,
|
||||
created_at integer NOT NULL,
|
||||
kind integer NOT NULL,
|
||||
tags text NOT NULL,
|
||||
content text NOT NULL,
|
||||
sig text NOT NULL
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX ididx ON event (id);
|
||||
CREATE INDEX pubkeytimeidx ON event (pubkey, created_at);
|
||||
`)
|
||||
return db, nil
|
||||
}
|
||||
Reference in New Issue
Block a user