model.3.0.0.anubis
4.79 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
read types/db_model.anubis
public define DB_Table settings_table =
db_table("settings",
db_model(
[
db_column("id", p_key, []),
db_column("var_name", char_field(20), []),
db_column("var_value", char_field(20), []),
],
"obj.var_name+\" = \"+obj.var_value"
),
db_display(
//list_view
["var_name", "var_value"],
//list edit
["type"]
)
).
public define DB_Table production_memory_type_table =
db_table("production_memory_type",
db_model(
[
db_column("id", p_key, []),
db_column("type", char_field(20), []),
],
"to_String(obj.id)+\":\"+obj.type"
),
db_display(
//list_view
["id", "type"],
//list edit
["type"]
)
).
public define DB_Table production_mass_storage_type_table =
db_table("production_mass_storage_type",
db_model(
[
db_column("id", p_key, []),
db_column("type", char_field(20), []),
],
"to_String(obj.id)+\":\"+obj.type"
),
db_display(
//list_view
["id", "type"],
//list edit
["type"]
)
).
public define DB_Table production_mass_storage_model_table =
db_table("production_mass_storage_model",
db_model(
[
db_column("id", p_key, []),
db_column("manufacturer", char_field(20), []),
db_column("type_id", foreign_key("production_mass_storage_type"), [indexed]),
db_column("capacity", integer_field, []), //
db_column("tr_min", integer_field, []), //
db_column("date_created", datetime_field(auto_now_add), []),
db_column("last_modified", datetime_field(auto_now), []),
db_column("comments", text_field, []) // whatever the user wants to keep
],
"obj.manufacturer"
),
db_display(
//list_view
["id", "manufacturer", "type_id", "capacity", "tr_min", "last_modified", "date_created"],
//list_edit
[]
)
).
public define DB_Table production_mass_storage_table =
db_table("production_mass_storage",
db_model(
[
db_column("id", p_key, []),
db_column("purchase_id", foreign_key("production_purchase"), [indexed]),
db_column("model_id", foreign_key("production_mass_storage_model"), [indexed]),
db_column("serial", char_field(40), []), //
db_column("status", char_field(10), []), //
db_column("date_created", datetime_field(auto_now_add), []),
db_column("last_modified", datetime_field(auto_now), []),
db_column("comments", text_field, []) // whatever the user wants to keep
],
"obj.purchase_id.string"
),
db_display(
//list_view
["model_id", "serial", "status", "date_created"],
//list_edit
["purchase_id", "model_id", "serial", "status", "comments"]
)
).
"CREATE TABLE production_purchase (
id integer NOT NULL PRIMARY KEY,
date date NOT NULL,
buyer_id integer NOT NULL REFERENCES staff_staff (id),
supplier_id integer NOT NULL REFERENCES production_supplier (id),
order_ref varchar(50) NOT NULL,
description varchar(200) NOT NULL,
date_created datetime NOT NULL,
last_modified datetime NOT NULL,
comments text NOT NULL
)"
public define DB_Table production_purchase_table =
db_table("production_purchase",
db_model(
[
db_column("id", p_key, []),
db_column("date", date_field(none), []),
db_column("buyer_id", foreign_key("staff_staff"), [indexed]),
db_column("supplier_id", foreign_key("production_supplier"), [indexed]),
db_column("order_ref", char_field(50), []), //
db_column("description", char_field(200), []), // description of the purchase
db_column("date_created", datetime_field(auto_now_add), []),
db_column("last_modified", datetime_field(auto_now), []),
db_column("comments", text_field, []), // whatever the user wants to keep
],
""
),
db_display(
//list_view
["date", "supplier_id", "description"],
//list_edit
["date", "buyer_id", "supplier_id", "order_ref", "description", "comments"]
)
).
public define DB_Database
the_database_description
=
db_database("prod_manager",
[
settings_table,
production_mass_storage_type_table,
production_mass_storage_model_table,
production_memory_type_table
//production_mass_storage_table,
//production_purchase_table
]).