diff --git a/ingest/ingest.go b/ingest/ingest.go index 2af7c98..1be0808 100644 --- a/ingest/ingest.go +++ b/ingest/ingest.go @@ -60,7 +60,7 @@ func Ingest(o IngestOpts) error { id SERIAL PRIMARY KEY, sourceid char(7) NOT NULL, phrase TEXT, - FOREIGN KEY (sourceid) REFERENCES sources(id) + FOREIGN KEY (sourceid) REFERENCES sources(id) ON DELETE CASCADE )`, tablename)) if err != nil { return fmt.Errorf("could not create table '%s': %w", tablename, err) diff --git a/phrasedb.sql b/phrasedb.sql index 3d3cb94..1d438f0 100644 --- a/phrasedb.sql +++ b/phrasedb.sql @@ -14,7 +14,7 @@ CREATE TABLE IF NOT EXISTS sources ( corpusid char(7) NOT NULL, name TEXT UNIQUE, - FOREIGN KEY (corpusid) REFERENCES corpora(id) + FOREIGN KEY (corpusid) REFERENCES corpora(id) ON DELETE CASCADE ); -- CREATE TABLE IF NOT EXISTS phrases (