Changeset 1427 for trunk/LATMOS-Accounts/bin
- Timestamp:
- 10/28/15 21:30:40 (9 years ago)
- Location:
- trunk/LATMOS-Accounts/bin
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LATMOS-Accounts/bin/la-sql-upgrade.in
r1391 r1427 610 610 FOR EACH ROW 611 611 EXECUTE PROCEDURE rev_tg_aliases_f(); 612 }, 613 ], 614 }, 615 { 616 ver => 13, 617 sql => [ 618 q{ 619 CREATE TABLE "stat" 620 ( 621 name text NOT NULL, 622 CONSTRAINT stat_pkey PRIMARY KEY (name), 623 CONSTRAINT stat_okey_uniq UNIQUE (ikey) 624 ) 625 INHERITS (objects); 626 CREATE INDEX stat_exported_idx 627 ON stat USING btree (exported); 628 CREATE UNIQUE INDEX stat_rev_idx 629 ON stat USING btree (rev); 630 631 CREATE OR REPLACE FUNCTION stat_attr_update_ref() 632 RETURNS trigger AS 633 $BODY$begin 634 635 IF (TG_OP != 'INSERT') then 636 update "stat" set date = now() where "stat".ikey = old.okey; 637 end if; 638 IF (TG_OP != 'DELETE') then 639 update "stat" set date = now() where "stat".ikey = new.okey; 640 end if; 641 642 IF (TG_OP = 'DELETE') then 643 return old; 644 ELSE 645 return new; 646 END IF; 647 648 END;$BODY$ 649 LANGUAGE plpgsql VOLATILE 650 COST 100; 651 }, 652 q{ 653 CREATE TABLE stat_attributes 654 ( 655 CONSTRAINT stat_attributes_pkey PRIMARY KEY (attr_key), 656 CONSTRAINT stat FOREIGN KEY (okey) 657 REFERENCES stat (ikey) MATCH SIMPLE 658 ON UPDATE CASCADE ON DELETE CASCADE 659 ) 660 INHERITS (attributes); 661 CREATE INDEX stat_attributes_attr_fkey 662 ON stat_attributes 663 USING btree 664 (attr COLLATE pg_catalog."default"); 665 CREATE INDEX stat_attr_value_idx 666 ON stat_attributes 667 USING btree 668 (value COLLATE pg_catalog."default"); 669 CREATE TRIGGER stat_attr_update 670 AFTER INSERT OR UPDATE OR DELETE 671 ON stat_attributes 672 FOR EACH ROW 673 EXECUTE PROCEDURE stat_attr_update_ref(); 674 }, 675 q{ 676 CREATE TABLE stat_attributes_list 677 ( 678 CONSTRAINT stat_attr_list_pkey PRIMARY KEY (ikey), 679 CONSTRAINT stat_attr_l_c_uniq UNIQUE (canonical) 680 ) 681 INHERITS (revisions, attributes_list); 682 }, 683 q{ 684 CREATE TABLE statsentry 685 ( 686 okey integer NOT NULL, 687 id bigint NOT NULL DEFAULT nextval('revisions_rev_seq'::regclass), 688 tstamp timestamp with time zone NOT NULL DEFAULT now(), 689 CONSTRAINT stat FOREIGN KEY (okey) 690 REFERENCES stat (ikey) MATCH SIMPLE 691 ON UPDATE CASCADE ON DELETE CASCADE, 692 CONSTRAINT statsentry_pkey PRIMARY KEY (id) 693 ); 694 CREATE TABLE statvalues 695 ( 696 sid bigint NOT NULL, 697 value text NOT NULL, 698 count bigint NOT NULL, 699 CONSTRAINT statvalues_pkey PRIMARY KEY (sid, value), 700 CONSTRAINT statvalues_fkey FOREIGN KEY (sid) 701 REFERENCES statsentry (id) MATCH SIMPLE 702 ON UPDATE CASCADE ON DELETE CASCADE 703 ) 612 704 }, 613 705 ], … … 650 742 } 651 743 } 652 $dbi->do($sql) or die "Erreur :\\" . $dbi->errstr . "\n"; 744 my $err = $dbi->do($sql); 745 warn $err; 746 defined($err) or die "Erreur :\\" . $dbi->errstr . "\n"; 653 747 } 654 748
Note: See TracChangeset
for help on using the changeset viewer.