From 2daa036a53f734deca236d2d05f50b869fac00bd Mon Sep 17 00:00:00 2001 From: Jonathan Treffler Date: Wed, 30 Oct 2024 04:39:31 +0100 Subject: [PATCH] added migration to create resource_members table --- .../Version000000Date20241025120000.php | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 lib/Migration/Version000000Date20241025120000.php diff --git a/lib/Migration/Version000000Date20241025120000.php b/lib/Migration/Version000000Date20241025120000.php new file mode 100644 index 0000000..1ed9a5b --- /dev/null +++ b/lib/Migration/Version000000Date20241025120000.php @@ -0,0 +1,74 @@ +hasTable(self::RESOURCE_MEMBERS_TABLE)) { + $table = $schema->createTable(self::RESOURCE_MEMBERS_TABLE); + $table->addColumn('id', Types::INTEGER, [ + 'autoincrement' => true, + 'notnull' => true, + ]); + $table->addColumn('resource_id', Types::INTEGER, [ + 'notnull' => true, + ]); + // 0: member + // 1: manager + $table->addColumn('permission_level', Types::INTEGER, [ + 'notnull' => true, + ]); + // 0: user + // 1: group + // 2: role + $table->addColumn('type', Types::INTEGER, [ + 'notnull' => true, + ]); + // for type user: "[user_id]" + // for type group: "[group_name]" + // for type role: "[organization_provider_id]:[role_id]" + $table->addColumn('principal', Types::STRING, [ + 'length' => 128, + 'notnull' => true, + ]); + $table->addColumn('created_timestamp', Types::BIGINT, [ + 'notnull' => true, + ]); + $table->addColumn('last_updated_timestamp', Types::BIGINT, [ + 'notnull' => true, + ]); + + $table->setPrimaryKey(['id']); + $table->addForeignKeyConstraint( + $schema->getTable(self::RESOURCES_TABLE), + ['resource_id'], + ['id'], + ['onDelete' => 'CASCADE'], + 'organizationfolders_resource_members_resource_id_fk'); + $table->addIndex(['resource_id'], 'organizationfolders_resource_members_resource_id_index'); + } + + return $schema; + } +} \ No newline at end of file