feat:挂单
This commit is contained in:
1 parent
988247f3cd
commit
2b956342f4
12 files changed
+545
-36
No files matched your search
@@ -85,9 +85,11 @@ abstract class AppDatabase extends FloorDatabase {
|
||||
CREATE TABLE IF NOT EXISTS order_hold_bill (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
sysType TEXT NOT NULL,
|
||||
orderListJson TEXT,
|
||||
carListJson TEXT,
|
||||
userJson TEXT,
|
||||
orderJson TEXT,
|
||||
price INTEGER DEFAULT 0 NOT NULL,
|
||||
extraPrice INTEGER DEFAULT 0 NOT NULL,
|
||||
payPrice INTEGER DEFAULT 0 NOT NULL,
|
||||
createTime TEXT NOT NULL
|
||||
)
|
||||
''');
|
||||
@@ -101,16 +103,22 @@ abstract class AppDatabase extends FloorDatabase {
|
||||
final columns =
|
||||
await database.rawQuery("PRAGMA table_info(order_hold_bill)");
|
||||
bool hasSysType = false;
|
||||
bool hasCarListJson = false;
|
||||
bool hasOrderListJson = false;
|
||||
bool hasUserJson = false;
|
||||
bool hasOrderJson = false;
|
||||
bool hasPrice = false;
|
||||
bool hasExtraPrice = false;
|
||||
bool hasPayPrice = false;
|
||||
bool hasCreateTime = false;
|
||||
for (final c in columns) {
|
||||
final name = c['name'];
|
||||
if (name == 'sysType') hasSysType = true;
|
||||
if (name == 'carListJson') hasCarListJson = true;
|
||||
if (name == 'orderListJson') hasOrderListJson = true;
|
||||
if (name == 'userJson') hasUserJson = true;
|
||||
if (name == 'orderJson') hasOrderJson = true;
|
||||
if (name == 'price') hasPrice = true;
|
||||
if (name == 'extraPrice') hasExtraPrice = true;
|
||||
if (name == 'payPrice') hasPayPrice = true;
|
||||
if (name == 'createTime') hasCreateTime = true;
|
||||
}
|
||||
if (!hasSysType) {
|
||||
@@ -118,24 +126,40 @@ abstract class AppDatabase extends FloorDatabase {
|
||||
'ALTER TABLE order_hold_bill ADD COLUMN sysType TEXT',
|
||||
);
|
||||
}
|
||||
if (!hasOrderListJson) {
|
||||
if (!hasCarListJson) {
|
||||
await database.execute(
|
||||
'ALTER TABLE order_hold_bill ADD COLUMN orderListJson TEXT',
|
||||
'ALTER TABLE order_hold_bill ADD COLUMN carListJson TEXT',
|
||||
);
|
||||
if (hasOrderListJson) {
|
||||
// 旧列迁移到新列
|
||||
await database.execute(
|
||||
"UPDATE order_hold_bill SET carListJson = orderListJson WHERE carListJson IS NULL",
|
||||
);
|
||||
}
|
||||
}
|
||||
if (!hasUserJson) {
|
||||
await database.execute(
|
||||
'ALTER TABLE order_hold_bill ADD COLUMN userJson TEXT',
|
||||
);
|
||||
}
|
||||
if (!hasOrderJson) {
|
||||
if (!hasPrice) {
|
||||
await database.execute(
|
||||
'ALTER TABLE order_hold_bill ADD COLUMN orderJson TEXT',
|
||||
'ALTER TABLE order_hold_bill ADD COLUMN price INTEGER DEFAULT 0 NOT NULL',
|
||||
);
|
||||
}
|
||||
if (!hasExtraPrice) {
|
||||
await database.execute(
|
||||
'ALTER TABLE order_hold_bill ADD COLUMN extraPrice INTEGER DEFAULT 0 NOT NULL',
|
||||
);
|
||||
}
|
||||
if (!hasPayPrice) {
|
||||
await database.execute(
|
||||
'ALTER TABLE order_hold_bill ADD COLUMN payPrice INTEGER DEFAULT 0 NOT NULL',
|
||||
);
|
||||
}
|
||||
if (!hasCreateTime) {
|
||||
await database.execute(
|
||||
'ALTER TABLE order_hold_bill ADD COLUMN createTime TEXT',
|
||||
'ALTER TABLE order_hold_bill ADD COLUMN createTime TEXT DEFAULT "" NOT NULL',
|
||||
);
|
||||
}
|
||||
await database.execute(
|
||||
|
||||
Reference in new issue
Block a user