parent
e7176b6371
commit
1378aefa9c
14 changed files with 93 additions and 35 deletions
14
migrations/094_species_adoption_fees.sql
Normal file
14
migrations/094_species_adoption_fees.sql
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
CREATE TABLE adoption_fee_rules (
|
||||
species_code TEXT PRIMARY KEY,
|
||||
fee_before_sterilization INTEGER NOT NULL DEFAULT 200,
|
||||
fee_after_sterilization INTEGER NOT NULL DEFAULT 220,
|
||||
is_free INTEGER NOT NULL DEFAULT 0,
|
||||
updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
||||
FOREIGN KEY(species_code) REFERENCES ref_species(code) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
INSERT OR IGNORE INTO adoption_fee_rules(species_code,fee_before_sterilization,fee_after_sterilization)
|
||||
SELECT s.code,
|
||||
COALESCE((SELECT CAST(setting_value AS INTEGER) FROM app_settings WHERE setting_key='adoption_fee_unsterilized'),200),
|
||||
COALESCE((SELECT CAST(setting_value AS INTEGER) FROM app_settings WHERE setting_key='adoption_fee_sterilized'),220)
|
||||
FROM ref_species s;
|
||||
Loading…
Reference in a new issue