From 011f7f452cdd3f4f0be009c143e469fc046d4dfe Mon Sep 17 00:00:00 2001 From: iglocska Date: Fri, 26 May 2023 16:01:01 +0200 Subject: [PATCH] new: [enumerations] schema update added --- .../20230526000000_Enumerations.php | 116 ++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 config/Migrations/20230526000000_Enumerations.php diff --git a/config/Migrations/20230526000000_Enumerations.php b/config/Migrations/20230526000000_Enumerations.php new file mode 100644 index 0000000..cac527b --- /dev/null +++ b/config/Migrations/20230526000000_Enumerations.php @@ -0,0 +1,116 @@ +hasTable('enumeration_collections'); + if (!$exists) { + $enumerationCollectionsTable = $this->table('enumeration_collections', [ + 'signed' => false, + 'collation' => 'utf8mb4_unicode_ci' + ]); + $enumerationCollectionsTable + ->addColumn('id', 'integer', [ + 'autoIncrement' => true, + 'limit' => 10, + 'signed' => false, + ]) + ->addPrimaryKey('id') + ->addColumn('uuid', 'string', [ + 'null' => false, + 'limit' => 40, + 'collation' => 'ascii_general_ci', + 'encoding' => 'ascii', + ]) + ->addColumn('name', 'string', [ + 'null' => false, + 'limit' => 191, + 'collation' => 'utf8mb4_unicode_ci', + 'encoding' => 'utf8mb4', + ]) + ->addColumn('description', 'text', [ + 'default' => null, + 'null' => true + ]) + ->addColumn('target_model', 'string', [ + 'null' => false, + 'limit' => 255, + 'collation' => 'ascii_general_ci', + 'encoding' => 'ascii', + ]) + ->addColumn('target_field', 'string', [ + 'null' => false, + 'limit' => 255, + 'collation' => 'ascii_general_ci', + 'encoding' => 'ascii', + ]) + ->addColumn('enabled', 'boolean', [ + 'default' => 0, + ]) + ->addColumn('deleted', 'boolean', [ + 'default' => 0, + ]) + ->addColumn('created', 'datetime', [ + 'null' => false + ]) + ->addColumn('modified', 'datetime', [ + 'null' => false + ]) + ->addIndex('name') + ->addIndex('target_model') + ->addIndex('target_field') + ->addIndex('uuid', ['unique' => true]); + + $enumerationCollectionsTable->create(); + } + + + + $exists = $this->hasTable('enumerations'); + if (!$exists) { + $enumerationsTable = $this->table('enumerations', [ + 'signed' => false, + 'collation' => 'utf8mb4_unicode_ci' + ]); + $enumerationsTable + ->addColumn('id', 'integer', [ + 'autoIncrement' => true, + 'limit' => 10, + 'signed' => false, + ]) + ->addPrimaryKey('id') + ->addColumn('value', 'string', [ + 'null' => false, + 'limit' => 191, + 'collation' => 'utf8mb4_unicode_ci', + 'encoding' => 'utf8mb4', + ]) + ->addColumn('enumeration_collection_id', 'integer', [ + 'limit' => 10, + 'signed' => false, + 'null' => false + ]) + ->addIndex('value') + ->addIndex('enumeration_collection_id'); + $enumerationsTable->create(); + } + } +}