20221114122500_add_place_thing_table.sql 515 B

12345678910111213141516
  1. -- +goose Up
  2. CREATE TABLE place_thing
  3. (
  4. place_id INT NOT NULL,
  5. thing_id INT NOT NULL,
  6. created_at TIMESTAMP NOT NULL DEFAULT NOW(),
  7. CONSTRAINT fk_place_thing_place_id FOREIGN KEY (place_id) REFERENCES place (id),
  8. CONSTRAINT fk_place_thing_thing_id FOREIGN KEY (thing_id) REFERENCES thing (id)
  9. );
  10. CREATE UNIQUE INDEX idx_unique_place_thing ON place_thing (place_id, thing_id);
  11. CREATE INDEX idx_place_thing_thing ON place_thing (thing_id);
  12. -- +goose Down
  13. DROP TABLE place_thing;