File: 8_dbmigrate.sql

package info (click to toggle)
kraft 2.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,112 kB
  • sloc: cpp: 28,535; sql: 1,248; perl: 396; xml: 330; python: 101; sh: 92; makefile: 10
file content (50 lines) | stat: -rw-r--r-- 2,757 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
-- message Create Document Relations Table
CREATE TABLE DocTypeRelations (
  typeId INT NOT NULL,
  followerId INT NOT NULL,
  sequence   INT NOT NULL,

  PRIMARY KEY( typeId, followerId )
);

-- Acceptance of Order follows Offer
-- SELECT @item := docTypeID FROM DocTypes WHERE name="Offer";
-- SELECT @follower := docTypeID FROM DocTypes WHERE name="Acceptance of Order";
INSERT INTO DocTypeRelations VALUES( (SELECT docTypeID FROM DocTypes WHERE name="Offer"), 
                                     (SELECT docTypeID FROM DocTypes WHERE name="Acceptance of Order"), 1 );

-- Invoice follorws Offer
-- SELECT @item := docTypeID FROM DocTypes WHERE name="Offer";
-- SELECT @follower := docTypeID FROM DocTypes WHERE name="Invoice";
-- INSERT INTO DocTypeRelations VALUES( @item, @follower, 2 );
INSERT INTO DocTypeRelations VALUES( (SELECT docTypeID FROM DocTypes WHERE name="Offer"), 
                                     (SELECT docTypeID FROM DocTypes WHERE name="Invoice"), 2 );

-- Invoice follows Acceptance of Order
-- SELECT @item := docTypeID FROM DocTypes WHERE name="Acceptance of Order";
-- SELECT @follower := docTypeID FROM DocTypes WHERE name="Invoice";
-- INSERT INTO DocTypeRelations VALUES( @item, @follower, 3 );
INSERT INTO DocTypeRelations VALUES( (SELECT docTypeID FROM DocTypes WHERE name="Acceptance of Order"), 
                                     (SELECT docTypeID FROM DocTypes WHERE name="Invoice"), 3 );


-- Acceptance of Order follows Offer
-- SELECT @item := docTypeID FROM DocTypes WHERE name="Angebot";
-- SELECT @follower := docTypeID FROM DocTypes WHERE name="Auftragsbestätigung";
-- INSERT INTO DocTypeRelations VALUES( @item, @follower, 4 );
INSERT INTO DocTypeRelations VALUES( (SELECT docTypeID FROM DocTypes WHERE name="Angebot"), 
                                     (SELECT docTypeID FROM DocTypes WHERE name="Auftragsbestätigung"), 4 );

-- Invoice follorws Offer
-- SELECT @item := docTypeID FROM DocTypes WHERE name="Angebot";
-- SELECT @follower := docTypeID FROM DocTypes WHERE name="Rechnung";
-- INSERT INTO DocTypeRelations VALUES( @item, @follower, 5 );
INSERT INTO DocTypeRelations VALUES( (SELECT docTypeID FROM DocTypes WHERE name="Angebot"), 
                                     (SELECT docTypeID FROM DocTypes WHERE name="Rechnung"), 5 );

--  Invoice follows Acceptance of Order
-- SELECT @item := docTypeID FROM DocTypes WHERE name like "Auftragsbest%";
-- SELECT @follower := docTypeID FROM DocTypes WHERE name="Rechnung";
-- INSERT INTO DocTypeRelations VALUES( @item, @follower, 6 );
INSERT INTO DocTypeRelations VALUES( (SELECT docTypeID FROM DocTypes WHERE name="Auftragsbestätigung"), 
                                     (SELECT docTypeID FROM DocTypes WHERE name="Rechnung"), 6 );