Changeset 1489 for trunk/LATMOS-Accounts/bin
- Timestamp:
- 12/01/15 09:25:35 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LATMOS-Accounts/bin/la-sql-upgrade.in
r1464 r1489 714 714 ALTER TABLE objects ADD COLUMN modifiedby text; 715 715 }, 716 ], 717 }, 718 { 719 ver => 15, 720 sql => [ 721 q{ 722 CREATE TABLE "employment" 723 ( 724 name text NOT NULL, 725 "user" text NOT NULL, 726 firstday date NOT NULL default now(), 727 lastday date, 728 CONSTRAINT employment_pkey PRIMARY KEY (name), 729 CONSTRAINT employment_okey_uniq UNIQUE (ikey), 730 CONSTRAINT employment_user_fkey FOREIGN KEY ("user") 731 REFERENCES "user" (name) MATCH SIMPLE 732 ON UPDATE CASCADE ON DELETE CASCADE 733 ) 734 INHERITS (objects); 735 CREATE INDEX employment_exported_idx 736 ON employment USING btree (exported); 737 CREATE UNIQUE INDEX employment_rev_idx 738 ON employment USING btree (rev); 739 740 CREATE OR REPLACE FUNCTION employment_attr_update_ref() 741 RETURNS trigger AS 742 $BODY$begin 743 744 IF (TG_OP != 'INSERT') then 745 update "employment" set date = now() where "employment".ikey = old.okey; 746 end if; 747 IF (TG_OP != 'DELETE') then 748 update "employment" set date = now() where "employment".ikey = new.okey; 749 end if; 750 751 IF (TG_OP = 'DELETE') then 752 return old; 753 ELSE 754 return new; 755 END IF; 756 757 END;$BODY$ 758 LANGUAGE plpgsql VOLATILE 759 COST 100; 760 }, 761 q{ 762 CREATE TABLE employment_attributes 763 ( 764 CONSTRAINT employment_attributes_pkey PRIMARY KEY (attr_key), 765 CONSTRAINT employment FOREIGN KEY (okey) 766 REFERENCES employment (ikey) MATCH SIMPLE 767 ON UPDATE CASCADE ON DELETE CASCADE 768 ) 769 INHERITS (attributes); 770 CREATE INDEX employment_attributes_attr_fkey 771 ON employment_attributes 772 USING btree 773 (attr); 774 CREATE INDEX employment_attr_value_idx 775 ON employment_attributes 776 USING btree 777 (value); 778 CREATE TRIGGER employment_attr_update 779 AFTER INSERT OR UPDATE OR DELETE 780 ON employment_attributes 781 FOR EACH ROW 782 EXECUTE PROCEDURE employment_attr_update_ref(); 783 }, 784 q{ 785 CREATE TABLE employment_attributes_list 786 ( 787 CONSTRAINT employment_attr_list_pkey PRIMARY KEY (ikey), 788 CONSTRAINT employment_attr_l_c_uniq UNIQUE (canonical) 789 ) 790 INHERITS (revisions, attributes_list); 791 }, 792 q{ 793 CREATE INDEX employment_firstday_idx 794 ON employment 795 USING btree 796 (firstday NULLS FIRST); 797 CREATE INDEX employment_lastday_idx 798 ON employment 799 USING btree 800 (lastday NULLS LAST); 716 801 ], 717 802 },
Note: See TracChangeset
for help on using the changeset viewer.