summaryrefslogtreecommitdiff
path: root/util/dbdump.pl
AgeCommit message (Collapse)AuthorFilesLines
2024-03-28!BREAKING! Restructure directory layout for generated & runtime filesYorhel1-5/+6
My testing, deployment and backup scripts were getting more complicated with files from various stages being lumped into a single directory structure, so all generated files (= anything touched by 'make') and runtime files (= anything touched by the web backend or multi) have now been moved into separate directories. These directories are also configurable with $VNDB_GEN and $VNDB_VAR, making it possible to manage multiple instances from a single source checkout. I also got rid of *data/* and *dl/* while I was at it, and moved *static/st/* (that is, the screenshot thumbnails) to */sf.t/*, to be consistent with the newer and more flexible image directory naming scheme. This commit breaks all existing installations and upgrading requires manual action. General upgrade instructions: # BEFORE doing a checkout of this commit make clean # AFTER make mkdir -p var/static var/log mv static/st var/static/sf.t mv static/{sf,ch,cv}{,.orig} var/static/ mv data/conf.pl var/ mv data/log var/ mv data/hibp var/ mv dl var/ util/setup-var.sh Use `git status` find leftover files to clean up or move. Don't forget to update conf.pl and web server configuration to make sure they access the new paths.
2024-03-21dbdump: Fix image export scriptYorhel1-3/+3
2024-03-20Add support for account soft-deletion and email opt-out listYorhel1-56/+72
This work is to support a safe self-service account deletion feature, but I haven't implemented that part yet.
2024-01-08Add some SQL comments to the database dumpsYorhel1-0/+14
So we have a little bit more documentation on SQLBin's schema page: https://sqlbin.vndb.org/schema
2023-09-15SQL/quotes: Add "approved" flag and improve randomisationYorhel1-1/+1
2023-05-03SQL: Rename columns that are SQL keywordsYorhel1-3/+3
So that there aren't any columns in need of quoting anymore.
2023-03-05dbdump.pl: Warn instead of error on (un)link failure in export-imgYorhel1-8/+7
The standby server filesystem may lag behind a bit on the database, but that's not really a problem for these exports.
2023-03-04dbdump.pl: Support dumping from a standby server + cleanup output dirYorhel1-6/+20
2022-10-31dbdump.pl: Improve performance of dumping ulist_vnsYorhel1-9/+40
Going from 29s before the merge to 35s after the merge to 7s with this change.
2022-10-31SQL: Merge ulist_vns_labels into ulist_vns as array + cache private flagYorhel1-13/+10
This reduces the database size a bit and slightly simplifies and significantly speeds up certain queries. Touches a fair amount of tricky code, so I'm sure there's bugs. The only visible change I'm aware of is that the deprecated 'get/set wishlist' API command now doesn't handle priorities anymore.
2022-09-28WIP add language-specific titles to releasesYorhel1-1/+1
2022-08-25Staff editionsYorhel1-1/+3
As discussed in https://vndb.org/t13027 and from https://vndb.org/t6138.327 onwards.
2022-04-29SQL: Move utility functions to separate util.sqlYorhel1-1/+2
This is a cleaner solution to the problem of the schema relying on a few utility functions and creating a dependency cycle between schema.sql and func.sql. Also fix dbdump.pl to not export generated columns. These changes are to prepare for an upgrade to PostgreSQL 14 with a clean import through dbdump.pl. Which appears to work surprisingly well in my testing so far.
2022-03-29VN length voting: support private votesYorhel1-2/+2
The database model supports private votes with a proper speed setting, but that is currently not possible through the UI.
2022-02-08VN: Add support for multiple titles in different languagesYorhel1-0/+1
This implements the main database model part of custom title languages (https://vndb.org/t12465). Selecting the right title for display is done in SQL through the 'vnt' VIEW, which can be overridden in each session with a TEMPORARY VIEW in order to support user title preferences, but that part has not been implemented yet. I had started out using an sql_vn() function that returned a subquery instead of using a VIEW, but then ran into trouble with the item_info() SQL function. This VIEW approach also happened to simplify much of the code. I did have to get rid of the Discusssions::Lib::sql_boards() function, as Postgres was unable to optimize the subquery inside a UNION inside a subquery for some reason. Haven't run into any other noticeable performance regressions yet. TODO: - Implement actual user title preferences - Add the correct 'lang' HTML attributes everywhere a title is displayed (we do have the information now, though it still isn't trivial) - Add title fetching support to API
2021-08-10Fix daily database dumpsYorhel1-2/+3
Which I broke in the previous two commits.
2021-08-03VNLengthVote: Add vote listing + aggregated stats + make publicYorhel1-1/+4
2021-05-21Tags/Traits: Add main/primary flag to parents listYorhel1-2/+2
This way there is always a single canonical path for each tag/trait, which fixes the problem with traits that could belong to multiple groups yet you couldn't control which one was selected, and this also removes duplication in the VN->tags tab, which now doesn't have to non-canonical tag paths.
2021-03-24Fix database exportYorhel1-1/+1
Huh, I thought I tested this.
2021-03-23Traits: Convert to vndbids + add edit historyYorhel1-6/+6
Much the same as the previous conversion of tags.
2021-03-11Tags: Convert to vndbids + add edit historiesYorhel1-9/+7
Another commit with changes all across the tree. But at least we have a tangible improvement now: edit histories for tags.
2021-03-01SQL: vndbid data type conversion for most DB entriesYorhel1-2/+2
I had wanted to split this up into multiple commits and roll out in stages, but couldn't really find a natural way to do so. There are several places that take a generic identifier and expect it to work the same for all entries they support, so changing one entry at a time wasn't going to be any easier. Only the tags & traits haven't been updated yet, I'll convert those later. While this is a major change and affects a lot of code, the individual changes are all pretty simple. I'm surprised how much code did not have to be updated at all. No doubt I've missed a few places, though, so this commit will almost certainly break something.
2021-02-24dbdump.pl: Add export-data command to dump everythingYorhel1-2/+51
Roughly similar to 'pg_dump --data-only', but with added includes for sql/ scripts, without the SET commands (these will cause the includes to fail) and with a "free" built-in CLUSTER on the primary key for most tables.
2020-12-29DB dumps: also export the quotes tableYorhel1-0/+1
The full list of quotes used to be one of VNDB's most well guarded secrets, but it's been scraped often enough now that I might as well just make it public.
2020-04-05SQL: Add C-based "vndbid" type and use it for image IDsYorhel1-5/+10
I had already rambled on the current composite type solution in 583ae868dfd3c882a8d2dd40b5d5ed099170c1c2 and I had already explored a few alternatives. This was the one alternative I hadn't yet explored because I wasn't sure the operational complexity was going to be worth it, but after seeing how bad PostgreSQL was at optimizing queries with composite types, I figured I might as well just go with this approach. It improves performance of some queries by a *lot* (especially the image selection query) and it's pretty elegant and convenient to work with. Only downside is the complexity of compiling, installing and maintaining a vndbid.so library for PostgreSQL.
2020-03-19dbdump/imgflag: Make sure to include users who voted on imagesYorhel1-1/+2
2020-03-16imgflag: Initial schema + UI for image flaggingYorhel1-3/+2
Lots of TODO's left to work on, but you have to start somewhere. I've bumped the Docker image version because this change requires TUWF commit 74aad378d49592df4359ea8a9f6f36d4a0013c04 (Elm decoder for structs with more than 8 fields)
2020-03-12SQL: Use global "images" table for metadata of all images in the DBYorhel1-4/+7
In preparation for an image flagging feature. This replaces the 'screenshots' table. I played around with various implementations of a primary key for the images table; A single integer encoding both the type and id is most efficient, but kind of ugly to work with. Two separate columns are also ugly and force the creation of a separate 'image_type' column on all referencing tables. The current composite type isn't all that much better, but at least it makes it easy to keep treating the image id as a single entity. Old VNDB::* code still treats it as an integer with different namespaces, new VNWeb::* code treats it as a proper composite type.
2020-02-21SQL: Allow tags_vn.uid to be NULL for deleted usersYorhel1-1/+1
This fixes the issue of tag votes getting deleted when a user account is deleted, despite these votes being part of the kept "database contributions" mentioned in the privacy policy.
2019-12-24ulist: Export new lists in dbdump.pl, unexport old listsYorhel1-23/+30
Ended up exporting the 'users.ign_votes' column as well, as that's both easier and (potentially) more useful than not exporting ignored votes in the first place.
2019-12-08dbdump.pl: Do an explicit rollback before disconnecting the DBYorhel1-0/+1
Fixes a (harmless) warning: Issuing rollback() due to DESTROY without explicit disconnect() of DBD::Pg::db handle dbname=vndb at util/dbdump.pl line 247.
2019-12-07dbdump.pl: Ensure consistent exportsYorhel1-1/+2
Today's export had a little inconsistency caused by a database update while the export script was running.
2019-10-03SQL: Get rid of the users_prefs table, store preferences in users tableYorhel1-7/+6
This bloats the users table a little bit, but that's fine. The main advantage of this change is that we now have a proper schema for user preferences, rather than the schemaless key-value mess we had before. This commit also splits the 'tags_cat' preference up into tags_cont, tags_ero and tags_tech bools, as that's more compact to store and easier to work with. This commit also changes the 'notify_nodbedit' preference to 'notify_dbedit' with inverted meaning. The reason the value was negated in the first place was because the old schemaless approach did not support positive defaults.
2019-09-17Rename VNDBSchema to VNDB::Schema and let it figure out the root path itselfYorhel1-4/+4
I always avoided using the VNDB::* schema for non-web related utility modules, but thats pretty silly (especially as I'm slowly trying to move away from the old VNDB::* web code).
2019-08-21dbdump.pl: Make sure to include chars_vns relations with rid = NULLYorhel1-1/+1
2019-08-15Minor util/sql/ reorganization + Make devdump more robustYorhel1-1/+1
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.
2019-08-09Replace Wikipedia links with Wikidata IDsYorhel1-0/+4
+ Automatically fetch other links from Wikidata
2019-08-03dbdump.pl: Change export-img to maintain a hardlink dir insteadYorhel1-26/+38
For use with rsync daemon.
2019-07-25dbdump.pl: Be more silentYorhel1-2/+2
2019-07-22dbdump.pl: Actually include import.sql in the db dumpsYorhel1-1/+1
2019-07-22Move votes/traits/tags exports to dbdump.pl; Get rid of Multi::APIDumpYorhel1-0/+82
This provides more control over when the dumps are being made and makes it easier to generate quick dumps for debugging.
2019-07-21Add (fullish) database dumpsYorhel1-0/+251