table partitioning stuff
This commit is contained in:
parent
25147572f8
commit
92a35eb823
@ -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)
|
||||
}
|
||||
|
24
phrasedb.sql
24
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
|
||||
--);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user