File: 8_dbmigrate.sql

package info (click to toggle)
kraft 0.45-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,732 kB
  • sloc: cpp: 23,458; sql: 1,171; python: 623; xml: 105; sh: 3; makefile: 2
file content (39 lines) | stat: -rw-r--r-- 1,529 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

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( @item, @follower, 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 );

# 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 );


# 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 );

# 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 );

# 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 );