add work order milestones tables
parent
4d40742f7e
commit
ea6e872b4e
|
|
@ -11,7 +11,7 @@ const recordColumns = " recordCreate_userName varchar(30) not null," +
|
||||||
export const initializeDatabase = () => {
|
export const initializeDatabase = () => {
|
||||||
const lotOccupancyDB = sqlite(databasePath);
|
const lotOccupancyDB = sqlite(databasePath);
|
||||||
const row = lotOccupancyDB
|
const row = lotOccupancyDB
|
||||||
.prepare("select name from sqlite_master where type = 'table' and name = 'WorkOrderComments'")
|
.prepare("select name from sqlite_master where type = 'table' and name = 'WorkOrderMilestones'")
|
||||||
.get();
|
.get();
|
||||||
if (!row) {
|
if (!row) {
|
||||||
debugSQL("Creating " + databasePath);
|
debugSQL("Creating " + databasePath);
|
||||||
|
|
@ -356,6 +356,30 @@ export const initializeDatabase = () => {
|
||||||
.prepare("create index if not exists idx_workordercomments_datetime" +
|
.prepare("create index if not exists idx_workordercomments_datetime" +
|
||||||
" on WorkOrderComments (workOrderId, workOrderCommentDate, workOrderCommentTime)")
|
" on WorkOrderComments (workOrderId, workOrderCommentDate, workOrderCommentTime)")
|
||||||
.run();
|
.run();
|
||||||
|
lotOccupancyDB
|
||||||
|
.prepare("create table if not exists WorkOrderMilestoneTypes (" +
|
||||||
|
"workOrderMilestoneTypeId integer not null primary key autoincrement," +
|
||||||
|
" workOrderMilestoneType varchar(100) not null," +
|
||||||
|
" orderNumber smallint not null default 0," +
|
||||||
|
recordColumns +
|
||||||
|
")")
|
||||||
|
.run();
|
||||||
|
lotOccupancyDB
|
||||||
|
.prepare("create table if not exists WorkOrderMilestones (" +
|
||||||
|
"workOrderMilestoneId integer not null primary key autoincrement," +
|
||||||
|
" workOrderId integer not null," +
|
||||||
|
" workOrderMilestoneTypeId integer," +
|
||||||
|
" workOrderMilestoneDate integer not null check (workOrderMilestoneDate > 0)," +
|
||||||
|
" workOrderMilestoneTime integer not null check (workOrderMilestoneTime >= 0)," +
|
||||||
|
" workOrderMilestoneDescription text not null," +
|
||||||
|
" workOrderMilestoneCompletionDate integer check (workOrderMilestoneCompletionDate > 0)," +
|
||||||
|
" workOrderMilestoneCompletionTime integer check (workOrderMilestoneCompletionTime >= 0)," +
|
||||||
|
recordColumns +
|
||||||
|
"," +
|
||||||
|
" foreign key (workOrderId) references WorkOrders (workOrderId)," +
|
||||||
|
" foreign key (workOrderMilestoneTypeId) references WorkOrderMilestoneTypes (workOrderMilestoneTypeId)" +
|
||||||
|
")")
|
||||||
|
.run();
|
||||||
lotOccupancyDB.close();
|
lotOccupancyDB.close();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ export const initializeDatabase = (): boolean => {
|
||||||
|
|
||||||
const row = lotOccupancyDB
|
const row = lotOccupancyDB
|
||||||
.prepare(
|
.prepare(
|
||||||
"select name from sqlite_master where type = 'table' and name = 'WorkOrderComments'"
|
"select name from sqlite_master where type = 'table' and name = 'WorkOrderMilestones'"
|
||||||
)
|
)
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
|
|
@ -481,6 +481,36 @@ export const initializeDatabase = (): boolean => {
|
||||||
)
|
)
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
|
lotOccupancyDB
|
||||||
|
.prepare(
|
||||||
|
"create table if not exists WorkOrderMilestoneTypes (" +
|
||||||
|
"workOrderMilestoneTypeId integer not null primary key autoincrement," +
|
||||||
|
" workOrderMilestoneType varchar(100) not null," +
|
||||||
|
" orderNumber smallint not null default 0," +
|
||||||
|
recordColumns +
|
||||||
|
")"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
|
lotOccupancyDB
|
||||||
|
.prepare(
|
||||||
|
"create table if not exists WorkOrderMilestones (" +
|
||||||
|
"workOrderMilestoneId integer not null primary key autoincrement," +
|
||||||
|
" workOrderId integer not null," +
|
||||||
|
" workOrderMilestoneTypeId integer," +
|
||||||
|
" workOrderMilestoneDate integer not null check (workOrderMilestoneDate > 0)," +
|
||||||
|
" workOrderMilestoneTime integer not null check (workOrderMilestoneTime >= 0)," +
|
||||||
|
" workOrderMilestoneDescription text not null," +
|
||||||
|
" workOrderMilestoneCompletionDate integer check (workOrderMilestoneCompletionDate > 0)," +
|
||||||
|
" workOrderMilestoneCompletionTime integer check (workOrderMilestoneCompletionTime >= 0)," +
|
||||||
|
recordColumns +
|
||||||
|
"," +
|
||||||
|
" foreign key (workOrderId) references WorkOrders (workOrderId)," +
|
||||||
|
" foreign key (workOrderMilestoneTypeId) references WorkOrderMilestoneTypes (workOrderMilestoneTypeId)" +
|
||||||
|
")"
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
|
||||||
lotOccupancyDB.close();
|
lotOccupancyDB.close();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue