25 lines
1.1 KiB
JavaScript
25 lines
1.1 KiB
JavaScript
/**
|
|
* Product unit weight and minimum purchase quantity, plus per-method weight
|
|
* limits for shipping (max weight and free-shipping weight cap).
|
|
* @param {import('node-pg-migrate').MigrationBuilder} pgm
|
|
*/
|
|
export const up = (pgm) => {
|
|
pgm.sql(
|
|
`ALTER TABLE catalog_products ADD COLUMN IF NOT EXISTS unit_weight_kg numeric(8,3) NOT NULL DEFAULT 1`,
|
|
);
|
|
pgm.sql(
|
|
`ALTER TABLE catalog_products ADD COLUMN IF NOT EXISTS min_purchase_qty integer NOT NULL DEFAULT 1`,
|
|
);
|
|
pgm.sql(`ALTER TABLE shipping_methods ADD COLUMN IF NOT EXISTS max_weight_kg numeric(8,3) NULL`);
|
|
pgm.sql(
|
|
`ALTER TABLE shipping_methods ADD COLUMN IF NOT EXISTS free_shipping_max_weight_kg numeric(8,3) NULL`,
|
|
);
|
|
};
|
|
|
|
export const down = (pgm) => {
|
|
pgm.sql(`ALTER TABLE shipping_methods DROP COLUMN IF EXISTS free_shipping_max_weight_kg`);
|
|
pgm.sql(`ALTER TABLE shipping_methods DROP COLUMN IF EXISTS max_weight_kg`);
|
|
pgm.sql(`ALTER TABLE catalog_products DROP COLUMN IF EXISTS min_purchase_qty`);
|
|
pgm.sql(`ALTER TABLE catalog_products DROP COLUMN IF EXISTS unit_weight_kg`);
|
|
};
|