summaryrefslogtreecommitdiff
path: root/lib/Multi/Maintenance.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2019-08-15 16:17:13 +0200
committerYorhel <git@yorhel.nl>2019-08-15 16:17:16 +0200
commit5a173c85c30acd3c5d80f9a0b6dd250efb61ad81 (patch)
tree359fad2a80bdfad1e7358872cc29bea57dac5208 /lib/Multi/Maintenance.pm
parent30cdc48d9ddbfe5223ebcfe5cdff3cdab372d894 (diff)
Minor util/sql/ reorganization + Make devdump more robust
I never really liked the hack that devdump.pl had to use to temporarily disable triggers and references. This new importer first imports all schema-related things, then the data, then the functions and table attributes - like an actual database dump. This restructuring should also make it (slightly) easier to import the "near-complete" database dump, but that's still going to involve a fair amount of scripting. This also fixes #22 - the script now asks whether to import a 'dump.sql' if it exists.
Diffstat (limited to 'lib/Multi/Maintenance.pm')
-rw-r--r--lib/Multi/Maintenance.pm17
1 files changed, 3 insertions, 14 deletions
diff --git a/lib/Multi/Maintenance.pm b/lib/Multi/Maintenance.pm
index 738909a9..3739af1f 100644
--- a/lib/Multi/Maintenance.pm
+++ b/lib/Multi/Maintenance.pm
@@ -127,20 +127,9 @@ my %monthlies = (
# This only takes about 3 seconds to complete
vncache_full => 'SELECT update_vncache(id) FROM vn',
- # These shouldn't really be necessary, the triggers in PgSQL should keep
- # these up-to-date nicely. But these all take less a second to complete,
- # anyway.
- stats_users => q|UPDATE stats_cache SET count = (SELECT COUNT(*) FROM users)-1 WHERE section = 'users'|,
- stats_vn => q|UPDATE stats_cache SET count = (SELECT COUNT(*) FROM vn WHERE hidden = FALSE) WHERE section = 'vn'|,
- stats_rel => q|UPDATE stats_cache SET count = (SELECT COUNT(*) FROM releases WHERE hidden = FALSE) WHERE section = 'releases'|,
- stats_prod => q|UPDATE stats_cache SET count = (SELECT COUNT(*) FROM producers WHERE hidden = FALSE) WHERE section = 'producers'|,
- stats_chars => q|UPDATE stats_cache SET count = (SELECT COUNT(*) FROM chars WHERE hidden = FALSE) WHERE section = 'chars'|,
- stats_chars => q|UPDATE stats_cache SET count = (SELECT COUNT(*) FROM staff WHERE hidden = FALSE) WHERE section = 'staff'|,
- stats_tags => q|UPDATE stats_cache SET count = (SELECT COUNT(*) FROM tags WHERE state = 2) WHERE section = 'tags'|,
- stats_trait => q|UPDATE stats_cache SET count = (SELECT COUNT(*) FROM traits WHERE state = 2) WHERE section = 'traits'|,
- stats_thread=> q|UPDATE stats_cache SET count = (SELECT COUNT(*) FROM threads WHERE hidden = FALSE) WHERE section = 'threads'|,
- stats_posts => q|UPDATE stats_cache SET count = (SELECT COUNT(*) FROM threads_posts WHERE hidden = FALSE
- AND EXISTS(SELECT 1 FROM threads WHERE threads.id = tid AND threads.hidden = FALSE)) WHERE section = 'threads_posts'|,
+ # This shouldn't really be necessary, the triggers in PgSQL should keep
+ # these up-to-date nicely. But it takes less than a second, anyway.
+ stats_cache => 'SELECT update_stats_cache_full()',
);