summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2020-04-04 12:32:52 +0200
committerYorhel <git@yorhel.nl>2020-04-04 12:36:53 +0200
commita53e57953a9f4a9912c70901b3841fd30a80bd1d (patch)
treeaa548ae4aa862655742f86e5ae5c569be460091a
parenta1ed3e6a8601a061bfa9228e4856d604e4113464 (diff)
SQL reorg: Move util/sql/ to sql/ as a top-level dir
Been wanting to do this for a while... I've kept util/sql as a symlink for compatibility with the devdump, old update scripts and other code I may have forgotten. I'll remove it later.
-rw-r--r--.gitignore11
-rw-r--r--Makefile4
-rw-r--r--README.md4
-rw-r--r--lib/VNDB/Schema.pm8
-rw-r--r--sql/all.sql11
-rw-r--r--sql/data.sql (renamed from util/sql/data.sql)0
-rw-r--r--sql/func.sql (renamed from util/sql/func.sql)0
-rw-r--r--sql/perms.sql (renamed from util/sql/perms.sql)0
-rw-r--r--sql/schema.sql (renamed from util/sql/schema.sql)0
-rw-r--r--sql/superuser_init.sql (renamed from util/sql/superuser_init.sql)0
-rw-r--r--sql/tableattrs.sql (renamed from util/sql/tableattrs.sql)0
-rw-r--r--sql/triggers.sql (renamed from util/sql/triggers.sql)0
-rwxr-xr-xutil/devdump.pl16
-rwxr-xr-xutil/docker-init.sh6
l---------util/sql1
-rw-r--r--util/sql/all.sql11
-rwxr-xr-xutil/sqleditfunc.pl2
17 files changed, 33 insertions, 41 deletions
diff --git a/.gitignore b/.gitignore
index 53652ecf..c8f9e661 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,8 +6,6 @@
/data/passwords.dat
/elm/elm-stuff/
/elm/Gen/
-/elm3/elm-stuff/
-/elm3/Lib/Gen.elm
/static/f/js/
/static/f/icons.png
/static/f/icons.opt.png
@@ -22,19 +20,12 @@
/static/s/*/style.min.css
/static/s/*/style.min.css.gz
/static/s/*/boxbg.png
-/static/v3/elm.js
-/static/v3/elm-opt.js
-/static/v3/min.js
-/static/v3/min.js.gz
-/static/v3/min.css
-/static/v3/min.css.gz
-/static/v3/style.css
/static/ch
/static/cv
/static/sf
/static/st
/static/robots.txt
/static/api
-/util/sql/editfunc.sql
+/sql/editfunc.sql
/www/
*.swp
diff --git a/Makefile b/Makefile
index ef707368..972fcc8c 100644
--- a/Makefile
+++ b/Makefile
@@ -32,7 +32,7 @@ ALL_CLEAN=\
static/f/vndb.js \
static/f/v2rw.js \
data/icons/icons.css \
- util/sql/editfunc.sql \
+ sql/editfunc.sql \
$(shell ls static/s | sed -e 's/\(.\+\)/static\/s\/\1\/style.css/g')
PROD=\
@@ -54,7 +54,7 @@ clean:
cleaner: clean
rm -rf elm/elm-stuff
-util/sql/editfunc.sql: util/sqleditfunc.pl util/sql/schema.sql
+sql/editfunc.sql: util/sqleditfunc.pl sql/schema.sql
util/sqleditfunc.pl
static/ch static/cv static/sf static/st:
diff --git a/README.md b/README.md
index fe1f59ab..33be6269 100644
--- a/README.md
+++ b/README.md
@@ -92,7 +92,7 @@ util/multi.pl (application server, optional):
```
# Create the database & roles
- psql -U postgres -f util/sql/superuser_init.sql
+ psql -U postgres -f sql/superuser_init.sql
# Set a password for each database role:
echo "ALTER ROLE vndb LOGIN PASSWORD 'pwd1'" | psql -U postgres
@@ -100,7 +100,7 @@ util/multi.pl (application server, optional):
echo "ALTER ROLE vndb_multi LOGIN PASSWORD 'pwd3'" | psql -U postgres
# OPTION 1: Create an empty database:
- psql -U vndb -f util/sql/all.sql
+ psql -U vndb -f sql/all.sql
# OPTION 2: Import the development database (https://vndb.org/d8#3):
curl -L https://dl.vndb.org/dump/vndb-dev-latest.tar.gz | tar -xzf-
diff --git a/lib/VNDB/Schema.pm b/lib/VNDB/Schema.pm
index b6e476b6..2d6eb6f5 100644
--- a/lib/VNDB/Schema.pm
+++ b/lib/VNDB/Schema.pm
@@ -1,4 +1,4 @@
-# Utility functions to parse the files in util/sql/ and extract information and
+# Utility functions to parse the files in sql/ and extract information and
# perform a few simple sanity checks.
#
# This is not a full-blown SQL parser. The code makes all kinds of assumptions
@@ -31,7 +31,7 @@ my $ROOT = $INC{'VNDB/Schema.pm'} =~ s{/lib/VNDB/Schema\.pm}{}r;
sub schema {
my %schema;
my $table;
- open my $F, '<', "$ROOT/util/sql/schema.sql" or die "schema.sql: $!";
+ open my $F, '<', "$ROOT/sql/schema.sql" or die "schema.sql: $!";
while(<$F>) {
chomp;
next if /^\s*--/ || /^\s*$/;
@@ -86,7 +86,7 @@ sub schema {
# }
sub types {
my %types;
- open my $F, '<', "$ROOT/util/sql/schema.sql" or die "schema.sql: $!";
+ open my $F, '<', "$ROOT/sql/schema.sql" or die "schema.sql: $!";
while(<$F>) {
chomp;
if(/^CREATE TYPE ([^ ]+)/) {
@@ -110,7 +110,7 @@ sub types {
# ]
sub references {
my @ref;
- open my $F, '<', "$ROOT/util/sql/tableattrs.sql" or die "tableattrs.sql: $!";
+ open my $F, '<', "$ROOT/sql/tableattrs.sql" or die "tableattrs.sql: $!";
while(<$F>) {
chomp;
next if !/^\s*ALTER\s+TABLE\s+([^ ]+)\s+ADD\s+CONSTRAINT\s+([^ ]+)\s+FOREIGN\s+KEY\s+\(([^\)]+)\)\s*REFERENCES\s+([^ ]+)\s*\(([^\)]+)\)/;
diff --git a/sql/all.sql b/sql/all.sql
new file mode 100644
index 00000000..852719c2
--- /dev/null
+++ b/sql/all.sql
@@ -0,0 +1,11 @@
+-- NOTE: Make sure you're cd'ed in the vndb root directory before running this script
+
+\set ON_ERROR_STOP 1
+\i sql/schema.sql
+\i sql/data.sql
+\i sql/func.sql
+\i sql/editfunc.sql
+\i sql/tableattrs.sql
+\i sql/triggers.sql
+\set ON_ERROR_STOP 0
+\i sql/perms.sql
diff --git a/util/sql/data.sql b/sql/data.sql
index 3283c035..3283c035 100644
--- a/util/sql/data.sql
+++ b/sql/data.sql
diff --git a/util/sql/func.sql b/sql/func.sql
index f7eeccc1..f7eeccc1 100644
--- a/util/sql/func.sql
+++ b/sql/func.sql
diff --git a/util/sql/perms.sql b/sql/perms.sql
index d1b452c4..d1b452c4 100644
--- a/util/sql/perms.sql
+++ b/sql/perms.sql
diff --git a/util/sql/schema.sql b/sql/schema.sql
index a34bc998..a34bc998 100644
--- a/util/sql/schema.sql
+++ b/sql/schema.sql
diff --git a/util/sql/superuser_init.sql b/sql/superuser_init.sql
index 6e94167c..6e94167c 100644
--- a/util/sql/superuser_init.sql
+++ b/sql/superuser_init.sql
diff --git a/util/sql/tableattrs.sql b/sql/tableattrs.sql
index 00efbd48..00efbd48 100644
--- a/util/sql/tableattrs.sql
+++ b/sql/tableattrs.sql
diff --git a/util/sql/triggers.sql b/sql/triggers.sql
index 5768c55e..5768c55e 100644
--- a/util/sql/triggers.sql
+++ b/sql/triggers.sql
diff --git a/util/devdump.pl b/util/devdump.pl
index 40ef6848..f1529839 100755
--- a/util/devdump.pl
+++ b/util/devdump.pl
@@ -93,12 +93,12 @@ sub copy_entry {
open my $OUT, '>:utf8', 'dump.sql';
select $OUT;
- print "-- This file replaces 'util/sql/all.sql'.\n";
+ print "-- This file replaces 'sql/all.sql'.\n";
print "\\set ON_ERROR_STOP 1\n";
- print "\\i util/sql/schema.sql\n";
- print "\\i util/sql/data.sql\n";
- print "\\i util/sql/func.sql\n";
- print "\\i util/sql/editfunc.sql\n";
+ print "\\i sql/schema.sql\n";
+ print "\\i sql/data.sql\n";
+ print "\\i sql/func.sql\n";
+ print "\\i sql/editfunc.sql\n";
# Copy over all sequence values
my @seq = sort @{ $db->selectcol_arrayref(
@@ -171,8 +171,8 @@ sub copy_entry {
# Releases
copy_entry r => [qw/releases releases_lang releases_media releases_platforms releases_producers releases_vn/], $releases;
- print "\\i util/sql/tableattrs.sql\n";
- print "\\i util/sql/triggers.sql\n";
+ print "\\i sql/tableattrs.sql\n";
+ print "\\i sql/triggers.sql\n";
# Update some caches
print "SELECT tag_vn_calc(NULL);\n";
@@ -185,7 +185,7 @@ sub copy_entry {
print "UPDATE users u SET c_changes = (SELECT COUNT(*) FROM changes c WHERE c.requester = u.id);\n";
print "\\set ON_ERROR_STOP 0\n";
- print "\\i util/sql/perms.sql\n";
+ print "\\i sql/perms.sql\n";
select STDOUT;
close $OUT;
diff --git a/util/docker-init.sh b/util/docker-init.sh
index 4e34f753..e1cf1b68 100755
--- a/util/docker-init.sh
+++ b/util/docker-init.sh
@@ -65,8 +65,8 @@ pg_start() {
[ -f dump.sql ] && echo " Or e to import the existing dump.sql."
read -p "Choice: " opt
- make util/sql/editfunc.sql
- psql postgres -f util/sql/superuser_init.sql
+ make sql/editfunc.sql
+ psql postgres -f sql/superuser_init.sql
echo "ALTER ROLE vndb LOGIN" | psql postgres
echo "ALTER ROLE vndb_site LOGIN" | psql postgres
echo "ALTER ROLE vndb_multi LOGIN" | psql postgres
@@ -80,7 +80,7 @@ pg_start() {
psql -U vndb -f dump.sql
rm dump.sql
else
- psql -U vndb -f util/sql/all.sql
+ psql -U vndb -f sql/all.sql
fi
touch data/docker-pg/vndb-init-done
diff --git a/util/sql b/util/sql
new file mode 120000
index 00000000..44657b95
--- /dev/null
+++ b/util/sql
@@ -0,0 +1 @@
+../sql \ No newline at end of file
diff --git a/util/sql/all.sql b/util/sql/all.sql
deleted file mode 100644
index 1e01dd3f..00000000
--- a/util/sql/all.sql
+++ /dev/null
@@ -1,11 +0,0 @@
--- NOTE: Make sure you're cd'ed in the vndb root directory before running this script
-
-\set ON_ERROR_STOP 1
-\i util/sql/schema.sql
-\i util/sql/data.sql
-\i util/sql/func.sql
-\i util/sql/editfunc.sql
-\i util/sql/tableattrs.sql
-\i util/sql/triggers.sql
-\set ON_ERROR_STOP 0
-\i util/sql/perms.sql
diff --git a/util/sqleditfunc.pl b/util/sqleditfunc.pl
index 3375136a..2af28b6a 100755
--- a/util/sqleditfunc.pl
+++ b/util/sqleditfunc.pl
@@ -52,7 +52,7 @@ sub gensql {
}
-open my $F, '>', "$ROOT/util/sql/editfunc.sql" or die $!;
+open my $F, '>', "$ROOT/sql/editfunc.sql" or die $!;
print $F "-- Automatically generated by util/sqleditfunc.pl. DO NOT EDIT.\n";
print $F gensql $_ for sort grep $schema->{$_}{dbentry_type}, keys %$schema;