aboutsummaryrefslogtreecommitdiff
path: root/db/migrations
diff options
context:
space:
mode:
authorMarcus Eibrink-Lunzenauer <lunzenauer@elan-ev.de>2023-07-04 10:03:28 +0000
committerMarcus Eibrink-Lunzenauer <lunzenauer@elan-ev.de>2023-07-04 10:03:28 +0000
commitf88e5ececb7eba585ab4c563e7561136003b96ab (patch)
treea1b51fbaac2119161b5387d38f9aa7e2821a38fb /db/migrations
parent80a8a75ea6070650b86d4f6aa008bfb65b22f513 (diff)
Add stock images, closes #2482
Closes #2482 Merge request studip/studip!1788
Diffstat (limited to 'db/migrations')
-rw-r--r--db/migrations/5.4.7_create_stock_images_table.php41
-rw-r--r--db/migrations/5.4.8_add_image_type_to_structural_elements.php28
2 files changed, 69 insertions, 0 deletions
diff --git a/db/migrations/5.4.7_create_stock_images_table.php b/db/migrations/5.4.7_create_stock_images_table.php
new file mode 100644
index 0000000..e1a7b04
--- /dev/null
+++ b/db/migrations/5.4.7_create_stock_images_table.php
@@ -0,0 +1,41 @@
+<?php
+
+class CreateStockImagesTable extends Migration
+{
+ public function description()
+ {
+ return 'create table for stock images';
+ }
+
+ public function up()
+ {
+ $db = DBManager::get();
+ $query =
+ "CREATE TABLE IF NOT EXISTS `stock_images` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+
+ `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
+ `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
+ `license` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
+ `author` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
+
+ `mime_type` varchar(64) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL,
+ `size` int(10) UNSIGNED NOT NULL,
+ `width` int(10) UNSIGNED NOT NULL,
+ `height` int(10) UNSIGNED NOT NULL,
+ `palette` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
+ `tags` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
+
+ `mkdate` int(11) UNSIGNED NOT NULL,
+ `chdate` int(11) UNSIGNED NOT NULL,
+
+ PRIMARY KEY (`id`))";
+ $db->exec($query);
+ }
+
+ public function down()
+ {
+ $db = DBManager::get();
+ $db->exec('DROP TABLE IF EXISTS `stock_images`');
+ }
+}
diff --git a/db/migrations/5.4.8_add_image_type_to_structural_elements.php b/db/migrations/5.4.8_add_image_type_to_structural_elements.php
new file mode 100644
index 0000000..7a2600a
--- /dev/null
+++ b/db/migrations/5.4.8_add_image_type_to_structural_elements.php
@@ -0,0 +1,28 @@
+<?php
+
+class AddImageTypeToStructuralElements extends Migration
+{
+ public function description()
+ {
+ return 'Add field `image_type` to table `cw_structural_elements`';
+ }
+
+ public function up()
+ {
+ $db = DBManager::get();
+ $db->exec(
+ sprintf(
+ 'ALTER TABLE `cw_structural_elements` ' .
+ 'ADD `image_type` ENUM("%s", "%s") NOT NULL DEFAULT "%1$s" AFTER `image_id`',
+ \FileRef::class,
+ \StockImage::class
+ )
+ );
+ }
+
+ public function down()
+ {
+ $db = DBManager::get();
+ $db->exec('ALTER TABLE `cw_structural_elements` DROP `image_type`');
+ }
+}