Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin/bootstrap-mysql
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-03-28 10:01:50 +0200
committerErich Eckner <git@eckner.net>2018-03-28 10:01:50 +0200
commit6d6b37c0ad62d448503efadf613790d133a88465 (patch)
tree80d0a05759c32952601c4ff2693a19b359e42416 /bin/bootstrap-mysql
parent4fa201c2d4a452c5192b5bc0f1f2b020a914cf3b (diff)
bin/bootstrap-mysql: "ON DELETE SET NULL" for "NULL" columns
Diffstat (limited to 'bin/bootstrap-mysql')
-rwxr-xr-xbin/bootstrap-mysql9
1 files changed, 8 insertions, 1 deletions
diff --git a/bin/bootstrap-mysql b/bin/bootstrap-mysql
index 43a79af..5f51c07 100755
--- a/bin/bootstrap-mysql
+++ b/bin/bootstrap-mysql
@@ -234,10 +234,17 @@ if [ ! "$1" = 'slim' ]; then
tr ' ' '\n' | \
sed -n 's/^://;T;p' | \
while read -r link; do
- printf 'ALTER TABLE `%s` ADD FOREIGN KEY (`%s`) REFERENCES `%s` (`id`) ON UPDATE CASCADE ON DELETE CASCADE;\n' \
+ printf 'ALTER TABLE `%s` ADD FOREIGN KEY (`%s`) REFERENCES `%s` (`id`) ON UPDATE CASCADE ON DELETE ' \
"${table}" \
"${column}" \
"${link}"
+ if echo "${rest}" | \
+ grep -qwF 'NULL'; then
+ printf 'SET NULL'
+ else
+ printf 'CASCADE'
+ fi
+ printf ';\n'
done
fi
;;