From 5824bc0991a90f033ef288925a68df19164470b0 Mon Sep 17 00:00:00 2001
From: Thomas Lange <code@nerdmind.de>
Date: Thu, 1 Jul 2021 15:56:42 +0200
Subject: Update database schema: Make id columns unsigned

This commit updates the database schema and adds a new migration to
modify the signed integer columns to make them unsigned.
---
 core/db/migrations/5.sql | 13 +++++++++++++
 1 file changed, 13 insertions(+)
 create mode 100644 core/db/migrations/5.sql

(limited to 'core/db/migrations/5.sql')

diff --git a/core/db/migrations/5.sql b/core/db/migrations/5.sql
new file mode 100644
index 0000000..8e8ecd7
--- /dev/null
+++ b/core/db/migrations/5.sql
@@ -0,0 +1,13 @@
+ALTER TABLE `page` DROP FOREIGN KEY `page_user`;
+ALTER TABLE `post` DROP FOREIGN KEY `post_user`;
+
+ALTER TABLE `page` MODIFY `id` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
+	MODIFY `user` TINYINT UNSIGNED NOT NULL;
+ALTER TABLE `post` MODIFY `id` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
+	MODIFY `user` TINYINT UNSIGNED NOT NULL;
+ALTER TABLE `user` MODIFY `id` TINYINT UNSIGNED NOT NULL AUTO_INCREMENT;
+
+ALTER TABLE `page` ADD CONSTRAINT `page_user` FOREIGN KEY (`user`)
+	REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
+ALTER TABLE `post` ADD CONSTRAINT `post_user` FOREIGN KEY (`user`)
+	REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
-- 
cgit v1.2.3

