Skip to content

Instantly share code, notes, and snippets.

@byaussy
Last active August 8, 2020 22:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save byaussy/8b65b0e46082d235c4342309fd2f0c43 to your computer and use it in GitHub Desktop.
Save byaussy/8b65b0e46082d235c4342309fd2f0c43 to your computer and use it in GitHub Desktop.
-- billing rules
DELETE FROM billing_rules WHERE created_username = 'dm-batch-import';
DELETE FROM billing_rule_groups WHERE created_username = 'dm-batch-import';
SELECT setval(pg_get_serial_sequence('billing_rule_groups', 'id'),
(SELECT GREATEST(max(billing_rule_groups.id) + 1, 1000) FROM billing_rule_groups) ,
false);
SELECT setval(pg_get_serial_sequence('billing_rules', 'id'),
(SELECT GREATEST(max(billing_rules.id) + 1, 1000) FROM billing_rules) ,
false);
SELECT setval(pg_get_serial_sequence('custom_fee', 'id'),
(SELECT GREATEST(max(custom_fee.id) + 1, 1000) FROM custom_fee) ,
false);
-- billing profiles
DELETE FROM billing_preferences WHERE created_by = 'dm-batch-import';
DELETE FROM billing_profiles bp where id not in (select billing_profile_id as id from billing_preferences );
SELECT setval(pg_get_serial_sequence('billing_profiles', 'id'),
(SELECT GREATEST(max(billing_profiles.id) + 1, 1000) FROM billing_profiles) ,
false);
SELECT setval(pg_get_serial_sequence('billing_preferences', 'id'),
(SELECT GREATEST(max(billing_preferences.id) + 1, 1000) FROM billing_preferences) ,
false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment