summaryrefslogtreecommitdiff
path: root/sql/upgrade/1.2-1.3.sql
blob: d12ca25a492da0324012c041edfbf6cb0731a556 (plain)
  1. BEGIN;
  2. ALTER TABLE employee RENAME TO employees;
  3. CREATE TABLE locations (
  4. id SERIAL PRIMARY KEY,
  5. companyname text,
  6. address1 text,
  7. address2 text,
  8. city text,
  9. state text,
  10. country text,
  11. zipcode text
  12. );
  13. CREATE SEQUENCE employees_id_seq;
  14. SELECT setval('employees_id_seq', (select max(id) + 1 FROM employees));
  15. ALTER TABLE employees ADD COLUMN locations_id integer;
  16. ALTER TABLE employees ADD FOREIGN KEY (locations_id) REFERENCES locations(id);
  17. ALTER TABLE employees ALTER COLUMN id DROP DEFAULT;
  18. ALTER TABLE employees ALTER COLUMN id SET DEFAULT nextval('employee_id_seq');
  19. DROP RULE employee_id_track_i ON employees; -- no longer needed
  20. CREATE TABLE account_links AS
  21. COMMIT;