diff --git a/ingest/ingest.go b/ingest/ingest.go index e0a069f..5eaa0fc 100644 --- a/ingest/ingest.go +++ b/ingest/ingest.go @@ -57,12 +57,12 @@ func Ingest(o IngestOpts) error { corpusid := db.StrToID(o.Corpus) tablename := fmt.Sprintf("phrases_%s", corpusid) _, err = conn.Exec(context.Background(), - `CREATE TABLE $1 ( + fmt.Sprintf(`CREATE TABLE %s ( id SERIAL PRIMARY KEY, sourceid char(7) NOT NULL, phrase TEXT, FOREIGN KEY (sourceid) REFERENCES sources(id) - )`, tablename) + )`, tablename)) if err != nil { return fmt.Errorf("could not create table '%s': %w", tablename, err) } diff --git a/phrasedb.sql b/phrasedb.sql index 03cdd5b..3d3cb94 100644 --- a/phrasedb.sql +++ b/phrasedb.sql @@ -1,6 +1,8 @@ -DROP TABLE phrases; -DROP TABLE sources; -DROP TABLE CORPORA; +DROP SCHEMA public CASCADE; +CREATE SCHEMA public; + +--GRANT ALL ON SCHEMA public TO postgres; +GRANT ALL ON SCHEMA public TO public; CREATE TABLE IF NOT EXISTS corpora ( id char(7) PRIMARY KEY, @@ -12,14 +14,14 @@ CREATE TABLE IF NOT EXISTS sources ( corpusid char(7) NOT NULL, name TEXT UNIQUE, - FOREIGN KEY (corpusid) REFERENCES corpora(id) ON DELETE CASCADE + FOREIGN KEY (corpusid) REFERENCES corpora(id) ); -CREATE TABLE IF NOT EXISTS phrases ( - id SERIAL PRIMARY KEY, - sourceid char(7) NOT NULL, - phrase TEXT, - - FOREIGN KEY (sourceid) REFERENCES sources(id) ON DELETE CASCADE -); +-- CREATE TABLE IF NOT EXISTS phrases ( +-- id SERIAL PRIMARY KEY, +-- sourceid char(7) NOT NULL, +-- phrase TEXT, +-- +-- FOREIGN KEY (sourceid) REFERENCES sources(id) ON DELETE CASCADE +--);