From c791012bf7481746ccbc554fd8c3f299d8c0d71b Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 27 Mar 2026 00:51:08 +1300 Subject: [PATCH] (refactor): convert collection configs to Attribute/Index value objects --- app/config/collections/common.php | 4163 ++++++---------- app/config/collections/databases.php | 190 +- app/config/collections/logs.php | 145 +- app/config/collections/platform.php | 3011 +++++------- app/config/collections/projects.php | 4203 ++++++----------- app/config/collections/vectorsdb.php | 250 +- app/http.php | 25 +- src/Appwrite/Migration/Migration.php | 56 +- .../Databases/Http/Databases/Create.php | 11 +- .../Http/VectorsDB/Collections/Create.php | 18 +- .../Modules/Projects/Http/Projects/Create.php | 4 +- tests/unit/General/CollectionsTest.php | 2 +- 12 files changed, 4479 insertions(+), 7599 deletions(-) diff --git a/app/config/collections/common.php b/app/config/collections/common.php index 80bb717423..c39aa1fed9 100644 --- a/app/config/collections/common.php +++ b/app/config/collections/common.php @@ -1,2751 +1,1660 @@ [ - '$collection' => Database::METADATA, + '$collection' => '_metadata', '$id' => 'cache', 'name' => 'Cache', 'attributes' => [ - [ - '$id' => 'resource', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 255, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'resourceType', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 255, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('mimeType'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 255, // https://tools.ietf.org/html/rfc4288#section-4.2 - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'accessedAt', - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => 'signature', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 255, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], + new Attribute( + key: 'resource', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'resourceType', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'mimeType', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'accessedAt', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), + new Attribute( + key: 'signature', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), ], 'indexes' => [ - [ - '$id' => '_key_accessedAt', - 'type' => Database::INDEX_KEY, - 'attributes' => ['accessedAt'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => '_key_resource', - 'type' => Database::INDEX_KEY, - 'attributes' => ['resource'], - 'lengths' => [], - 'orders' => [], - ], + new Index( + key: '_key_accessedAt', + type: IndexType::Key, + attributes: ['accessedAt'], + ), + new Index( + key: '_key_resource', + type: IndexType::Key, + attributes: ['resource'], + ), ], ], - 'users' => [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('users'), + '$collection' => '_metadata', + '$id' => 'users', 'name' => 'Users', 'attributes' => [ - [ - '$id' => ID::custom('name'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('email'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 320, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('phone'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16, // leading '+' and 15 digitts maximum by E.164 format - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('status'), - 'type' => Database::VAR_BOOLEAN, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('labels'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => true, - 'filters' => [], - ], - [ - '$id' => ID::custom('passwordHistory'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => true, - 'filters' => [], - ], - [ - '$id' => ID::custom('password'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['encrypt'], - ], - [ - '$id' => 'hash', // Hashing algorithm used to hash the password - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => (new Argon2())->getName(), - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('hashOptions'), // Configuration of hashing algorithm - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 65535, - 'signed' => true, - 'required' => false, - 'default' => (new Argon2())->getOptions(), - 'array' => false, - 'filters' => ['json'], - ], - [ - '$id' => ID::custom('passwordUpdate'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('prefs'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 65535, - 'signed' => true, - 'required' => false, - 'default' => new \stdClass(), - 'array' => false, - 'filters' => ['json'], - ], - [ - '$id' => ID::custom('registration'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('emailVerification'), - 'type' => Database::VAR_BOOLEAN, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('phoneVerification'), - 'type' => Database::VAR_BOOLEAN, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('reset'), - 'type' => Database::VAR_BOOLEAN, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('mfa'), - 'type' => Database::VAR_BOOLEAN, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('mfaRecoveryCodes'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => [], - 'array' => true, - 'filters' => ['encrypt'], - ], - [ - '$id' => ID::custom('authenticators'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['subQueryAuthenticators'], - ], - [ - '$id' => ID::custom('sessions'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['subQuerySessions'], - ], - [ - '$id' => ID::custom('tokens'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['subQueryTokens'], - ], - [ - '$id' => ID::custom('challenges'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['subQueryChallenges'], - ], - [ - '$id' => ID::custom('memberships'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['subQueryMemberships'], - ], - [ - '$id' => ID::custom('targets'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['subQueryTargets'], - ], - [ - '$id' => ID::custom('search'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['userSearch'], - ], - [ - '$id' => ID::custom('accessedAt'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('emailCanonical'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 320, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('emailIsFree'), - 'type' => Database::VAR_BOOLEAN, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('emailIsDisposable'), - 'type' => Database::VAR_BOOLEAN, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('emailIsCorporate'), - 'type' => Database::VAR_BOOLEAN, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('emailIsCanonical'), - 'type' => Database::VAR_BOOLEAN, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('impersonator'), - 'type' => Database::VAR_BOOLEAN, - 'signed' => true, - 'size' => 0, - 'format' => '', - 'filters' => [], - 'required' => false, - 'default' => false, - 'array' => false, - ], + new Attribute( + key: 'name', + type: ColumnType::String, + size: 256, + ), + new Attribute( + key: 'email', + type: ColumnType::String, + size: 320, + ), + new Attribute( + key: 'phone', + type: ColumnType::String, + size: 16, + ), + new Attribute( + key: 'status', + type: ColumnType::Boolean, + ), + new Attribute( + key: 'labels', + type: ColumnType::String, + size: 128, + array: true, + ), + new Attribute( + key: 'passwordHistory', + type: ColumnType::String, + size: 16384, + array: true, + ), + new Attribute( + key: 'password', + type: ColumnType::String, + size: 16384, + filters: ['encrypt'], + ), + new Attribute( + key: 'hash', + type: ColumnType::String, + size: 256, + default: 'argon2', + ), + new Attribute( + key: 'hashOptions', + type: ColumnType::String, + size: 65535, + default: ['type' => 'argon2', 'memory_cost' => 65536, 'time_cost' => 4, 'threads' => 3], + filters: ['json'], + ), + new Attribute( + key: 'passwordUpdate', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), + new Attribute( + key: 'prefs', + type: ColumnType::String, + size: 65535, + default: (object) array( + ), + filters: ['json'], + ), + new Attribute( + key: 'registration', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), + new Attribute( + key: 'emailVerification', + type: ColumnType::Boolean, + ), + new Attribute( + key: 'phoneVerification', + type: ColumnType::Boolean, + ), + new Attribute( + key: 'reset', + type: ColumnType::Boolean, + ), + new Attribute( + key: 'mfa', + type: ColumnType::Boolean, + ), + new Attribute( + key: 'mfaRecoveryCodes', + type: ColumnType::String, + size: 256, + default: [], + array: true, + filters: ['encrypt'], + ), + new Attribute( + key: 'authenticators', + type: ColumnType::String, + size: 16384, + filters: ['subQueryAuthenticators'], + ), + new Attribute( + key: 'sessions', + type: ColumnType::String, + size: 16384, + filters: ['subQuerySessions'], + ), + new Attribute( + key: 'tokens', + type: ColumnType::String, + size: 16384, + filters: ['subQueryTokens'], + ), + new Attribute( + key: 'challenges', + type: ColumnType::String, + size: 16384, + filters: ['subQueryChallenges'], + ), + new Attribute( + key: 'memberships', + type: ColumnType::String, + size: 16384, + filters: ['subQueryMemberships'], + ), + new Attribute( + key: 'targets', + type: ColumnType::String, + size: 16384, + filters: ['subQueryTargets'], + ), + new Attribute( + key: 'search', + type: ColumnType::String, + size: 16384, + filters: ['userSearch'], + ), + new Attribute( + key: 'accessedAt', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), + new Attribute( + key: 'emailCanonical', + type: ColumnType::String, + size: 320, + ), + new Attribute( + key: 'emailIsFree', + type: ColumnType::Boolean, + ), + new Attribute( + key: 'emailIsDisposable', + type: ColumnType::Boolean, + ), + new Attribute( + key: 'emailIsCorporate', + type: ColumnType::Boolean, + ), + new Attribute( + key: 'emailIsCanonical', + type: ColumnType::Boolean, + ), + new Attribute( + key: 'impersonator', + type: ColumnType::Boolean, + default: false, + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_key_name'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['name'], - 'lengths' => [256], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_email'), - 'type' => Database::INDEX_UNIQUE, - 'attributes' => ['email'], - 'lengths' => [256], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_phone'), - 'type' => Database::INDEX_UNIQUE, - 'attributes' => ['phone'], - 'lengths' => [16], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_status'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['status'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_passwordUpdate'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['passwordUpdate'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_registration'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['registration'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_emailVerification'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['emailVerification'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_phoneVerification'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['phoneVerification'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_search'), - 'type' => Database::INDEX_FULLTEXT, - 'attributes' => ['search'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => '_key_accessedAt', - 'type' => Database::INDEX_KEY, - 'attributes' => ['accessedAt'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => ID::custom('impersonator'), - 'type' => Database::INDEX_KEY, - 'attributes' => [ID::custom('impersonator')], - 'lengths' => [], - 'orders' => [], - ], + new Index( + key: '_key_name', + type: IndexType::Key, + attributes: ['name'], + lengths: [256], + orders: ['ASC'], + ), + new Index( + key: '_key_email', + type: IndexType::Unique, + attributes: ['email'], + lengths: [256], + orders: ['ASC'], + ), + new Index( + key: '_key_phone', + type: IndexType::Unique, + attributes: ['phone'], + lengths: [16], + orders: ['ASC'], + ), + new Index( + key: '_key_status', + type: IndexType::Key, + attributes: ['status'], + orders: ['ASC'], + ), + new Index( + key: '_key_passwordUpdate', + type: IndexType::Key, + attributes: ['passwordUpdate'], + orders: ['ASC'], + ), + new Index( + key: '_key_registration', + type: IndexType::Key, + attributes: ['registration'], + orders: ['ASC'], + ), + new Index( + key: '_key_emailVerification', + type: IndexType::Key, + attributes: ['emailVerification'], + orders: ['ASC'], + ), + new Index( + key: '_key_phoneVerification', + type: IndexType::Key, + attributes: ['phoneVerification'], + orders: ['ASC'], + ), + new Index( + key: '_key_search', + type: IndexType::Fulltext, + attributes: ['search'], + ), + new Index( + key: '_key_accessedAt', + type: IndexType::Key, + attributes: ['accessedAt'], + ), + new Index( + key: 'impersonator', + type: IndexType::Key, + attributes: ['impersonator'], + ), ], ], - 'tokens' => [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('tokens'), + '$collection' => '_metadata', + '$id' => 'tokens', 'name' => 'Tokens', 'attributes' => [ - [ - '$id' => ID::custom('userInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('userId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('type'), - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('secret'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 512, // https://www.tutorialspoint.com/how-long-is-the-sha256-hash-in-mysql (512 for encryption) - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['encrypt'], - ], - [ - '$id' => ID::custom('expire'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('userAgent'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('ip'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 45, // https://stackoverflow.com/a/166157/2299554 - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ] + new Attribute( + key: 'userInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'userId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'type', + type: ColumnType::Integer, + required: true, + ), + new Attribute( + key: 'secret', + type: ColumnType::String, + size: 512, + filters: ['encrypt'], + ), + new Attribute( + key: 'expire', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), + new Attribute( + key: 'userAgent', + type: ColumnType::String, + size: 16384, + ), + new Attribute( + key: 'ip', + type: ColumnType::String, + size: 45, + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_key_user'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['userInternalId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], + new Index( + key: '_key_user', + type: IndexType::Key, + attributes: ['userInternalId'], + lengths: [255], + orders: ['ASC'], + ), ], ], - 'authenticators' => [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('authenticators'), + '$collection' => '_metadata', + '$id' => 'authenticators', 'name' => 'Authenticators', 'attributes' => [ - [ - '$id' => ID::custom('userInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('userId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('type'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('verified'), - 'type' => Database::VAR_BOOLEAN, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => false, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('data'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 65535, - 'signed' => true, - 'required' => false, - 'default' => [], - 'array' => false, - 'filters' => ['json', 'encrypt'], - ], + new Attribute( + key: 'userInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'userId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'type', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'verified', + type: ColumnType::Boolean, + default: false, + ), + new Attribute( + key: 'data', + type: ColumnType::String, + size: 65535, + default: [], + filters: ['json', 'encrypt'], + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_key_userInternalId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['userInternalId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ] + new Index( + key: '_key_userInternalId', + type: IndexType::Key, + attributes: ['userInternalId'], + lengths: [255], + orders: ['ASC'], + ), ], ], - 'challenges' => [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('challenges'), + '$collection' => '_metadata', + '$id' => 'challenges', 'name' => 'Challenges', 'attributes' => [ - [ - '$id' => ID::custom('userInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('userId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('type'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('token'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 512, // https://www.tutorialspoint.com/how-long-is-the-sha256-hash-in-mysql (512 for encryption) - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['encrypt'], - ], [ - '$id' => ID::custom('code'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 512, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['encrypt'], - ], [ - '$id' => ID::custom('expire'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ] + new Attribute( + key: 'userInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'userId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'type', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'token', + type: ColumnType::String, + size: 512, + filters: ['encrypt'], + ), + new Attribute( + key: 'code', + type: ColumnType::String, + size: 512, + filters: ['encrypt'], + ), + new Attribute( + key: 'expire', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_key_user'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['userInternalId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ] + new Index( + key: '_key_user', + type: IndexType::Key, + attributes: ['userInternalId'], + lengths: [255], + orders: ['ASC'], + ), ], ], - 'sessions' => [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('sessions'), + '$collection' => '_metadata', + '$id' => 'sessions', 'name' => 'Sessions', 'attributes' => [ - [ - '$id' => ID::custom('userInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('userId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('provider'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('providerUid'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2048, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('providerAccessToken'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['encrypt'], - ], - [ - '$id' => ID::custom('providerAccessTokenExpiry'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('providerRefreshToken'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['encrypt'], - ], - [ - '$id' => ID::custom('secret'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 512, // https://www.tutorialspoint.com/how-long-is-the-sha256-hash-in-mysql (512 for encryption) - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['encrypt'], - ], - [ - '$id' => ID::custom('userAgent'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('ip'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 45, // https://stackoverflow.com/a/166157/2299554 - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('countryCode'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('osCode'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('osName'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('osVersion'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('clientType'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('clientCode'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('clientName'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('clientVersion'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('clientEngine'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('clientEngineVersion'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('deviceName'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('deviceBrand'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('deviceModel'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('factors'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => [], - 'array' => true, - 'filters' => [], - ], - [ - '$id' => ID::custom('expire'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('mfaUpdatedAt'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], + new Attribute( + key: 'userInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'userId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'provider', + type: ColumnType::String, + size: 128, + ), + new Attribute( + key: 'providerUid', + type: ColumnType::String, + size: 2048, + ), + new Attribute( + key: 'providerAccessToken', + type: ColumnType::String, + size: 16384, + filters: ['encrypt'], + ), + new Attribute( + key: 'providerAccessTokenExpiry', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), + new Attribute( + key: 'providerRefreshToken', + type: ColumnType::String, + size: 16384, + filters: ['encrypt'], + ), + new Attribute( + key: 'secret', + type: ColumnType::String, + size: 512, + filters: ['encrypt'], + ), + new Attribute( + key: 'userAgent', + type: ColumnType::String, + size: 16384, + ), + new Attribute( + key: 'ip', + type: ColumnType::String, + size: 45, + ), + new Attribute( + key: 'countryCode', + type: ColumnType::String, + size: 2, + ), + new Attribute( + key: 'osCode', + type: ColumnType::String, + size: 256, + ), + new Attribute( + key: 'osName', + type: ColumnType::String, + size: 256, + ), + new Attribute( + key: 'osVersion', + type: ColumnType::String, + size: 256, + ), + new Attribute( + key: 'clientType', + type: ColumnType::String, + size: 256, + ), + new Attribute( + key: 'clientCode', + type: ColumnType::String, + size: 256, + ), + new Attribute( + key: 'clientName', + type: ColumnType::String, + size: 256, + ), + new Attribute( + key: 'clientVersion', + type: ColumnType::String, + size: 256, + ), + new Attribute( + key: 'clientEngine', + type: ColumnType::String, + size: 256, + ), + new Attribute( + key: 'clientEngineVersion', + type: ColumnType::String, + size: 256, + ), + new Attribute( + key: 'deviceName', + type: ColumnType::String, + size: 256, + ), + new Attribute( + key: 'deviceBrand', + type: ColumnType::String, + size: 256, + ), + new Attribute( + key: 'deviceModel', + type: ColumnType::String, + size: 256, + ), + new Attribute( + key: 'factors', + type: ColumnType::String, + size: 256, + default: [], + array: true, + ), + new Attribute( + key: 'expire', + type: ColumnType::Datetime, + required: true, + signed: false, + filters: ['datetime'], + ), + new Attribute( + key: 'mfaUpdatedAt', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_key_provider_providerUid'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['provider', 'providerUid'], - 'lengths' => [128, 128], - 'orders' => [Database::ORDER_ASC, Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_user'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['userInternalId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], + new Index( + key: '_key_provider_providerUid', + type: IndexType::Key, + attributes: ['provider', 'providerUid'], + lengths: [128, 128], + orders: ['ASC', 'ASC'], + ), + new Index( + key: '_key_user', + type: IndexType::Key, + attributes: ['userInternalId'], + lengths: [255], + orders: ['ASC'], + ), ], ], - 'identities' => [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('identities'), + '$collection' => '_metadata', + '$id' => 'identities', 'name' => 'Identities', 'attributes' => [ - [ - '$id' => ID::custom('userInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('userId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('provider'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('providerUid'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2048, // Decrease to 128 as in index length? - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('providerEmail'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 320, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('providerAccessToken'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['encrypt'], - ], - [ - '$id' => ID::custom('providerAccessTokenExpiry'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('providerRefreshToken'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['encrypt'], - ], - [ - // Used to store data from provider that may or may not be sensitive - '$id' => ID::custom('secrets'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => [], - 'array' => false, - 'filters' => ['json', 'encrypt'], - ], - [ - '$id' => ID::custom('scopes'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => true, - 'filters' => [], - ], - [ - '$id' => ID::custom('expire'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'required' => false, - 'signed' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], + new Attribute( + key: 'userInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'userId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'provider', + type: ColumnType::String, + size: 128, + ), + new Attribute( + key: 'providerUid', + type: ColumnType::String, + size: 2048, + ), + new Attribute( + key: 'providerEmail', + type: ColumnType::String, + size: 320, + ), + new Attribute( + key: 'providerAccessToken', + type: ColumnType::String, + size: 16384, + filters: ['encrypt'], + ), + new Attribute( + key: 'providerAccessTokenExpiry', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), + new Attribute( + key: 'providerRefreshToken', + type: ColumnType::String, + size: 16384, + filters: ['encrypt'], + ), + new Attribute( + key: 'secrets', + type: ColumnType::String, + size: 16384, + default: [], + filters: ['json', 'encrypt'], + ), + new Attribute( + key: 'scopes', + type: ColumnType::String, + size: Database::LENGTH_KEY, + array: true, + ), + new Attribute( + key: 'expire', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_key_userInternalId_provider_providerUid'), - 'type' => Database::INDEX_UNIQUE, - 'attributes' => ['userInternalId', 'provider', 'providerUid'], - 'lengths' => [11, 128, 128], // providerUid is length 2000! - 'orders' => [Database::ORDER_ASC, Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_provider_providerUid'), - 'type' => Database::INDEX_UNIQUE, - 'attributes' => ['provider', 'providerUid'], - 'lengths' => [128, 128], // providerUid is length 2000! - 'orders' => [Database::ORDER_ASC, Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_userId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['userId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_userInternalId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['userInternalId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_provider'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['provider'], - 'lengths' => [128], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_providerUid'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['providerUid'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_providerEmail'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['providerEmail'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_providerAccessTokenExpiry'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['providerAccessTokenExpiry'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], + new Index( + key: '_key_userInternalId_provider_providerUid', + type: IndexType::Unique, + attributes: ['userInternalId', 'provider', 'providerUid'], + lengths: [11, 128, 128], + orders: ['ASC', 'ASC'], + ), + new Index( + key: '_key_provider_providerUid', + type: IndexType::Unique, + attributes: ['provider', 'providerUid'], + lengths: [128, 128], + orders: ['ASC', 'ASC'], + ), + new Index( + key: '_key_userId', + type: IndexType::Key, + attributes: ['userId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_userInternalId', + type: IndexType::Key, + attributes: ['userInternalId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_provider', + type: IndexType::Key, + attributes: ['provider'], + lengths: [128], + orders: ['ASC'], + ), + new Index( + key: '_key_providerUid', + type: IndexType::Key, + attributes: ['providerUid'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_providerEmail', + type: IndexType::Key, + attributes: ['providerEmail'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_providerAccessTokenExpiry', + type: IndexType::Key, + attributes: ['providerAccessTokenExpiry'], + orders: ['ASC'], + ), ], ], - 'teams' => [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('teams'), + '$collection' => '_metadata', + '$id' => 'teams', 'name' => 'Teams', 'attributes' => [ - [ - '$id' => ID::custom('name'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('total'), - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('search'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('prefs'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 65535, - 'signed' => true, - 'required' => false, - 'default' => new \stdClass(), - 'array' => false, - 'filters' => ['json'], - ], - [ - '$id' => ID::custom('labels'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => true, - 'filters' => [], - ], + new Attribute( + key: 'name', + type: ColumnType::String, + size: 128, + ), + new Attribute( + key: 'total', + type: ColumnType::Integer, + ), + new Attribute( + key: 'search', + type: ColumnType::String, + size: 16384, + ), + new Attribute( + key: 'prefs', + type: ColumnType::String, + size: 65535, + default: (object) array( + ), + filters: ['json'], + ), + new Attribute( + key: 'labels', + type: ColumnType::String, + size: 128, + array: true, + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_key_search'), - 'type' => Database::INDEX_FULLTEXT, - 'attributes' => ['search'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => ID::custom('_key_name'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['name'], - 'lengths' => [128], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_total'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['total'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], + new Index( + key: '_key_search', + type: IndexType::Fulltext, + attributes: ['search'], + ), + new Index( + key: '_key_name', + type: IndexType::Key, + attributes: ['name'], + lengths: [128], + orders: ['ASC'], + ), + new Index( + key: '_key_total', + type: IndexType::Key, + attributes: ['total'], + orders: ['ASC'], + ), ], ], - 'memberships' => [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('memberships'), + '$collection' => '_metadata', + '$id' => 'memberships', 'name' => 'Memberships', 'attributes' => [ - [ - '$id' => ID::custom('userInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('userId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('teamInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('teamId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('roles'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => true, - 'filters' => [], - ], - [ - '$id' => ID::custom('invited'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('joined'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('confirm'), - 'type' => Database::VAR_BOOLEAN, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('secret'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['encrypt'], - ], - [ - '$id' => ID::custom('search'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], + new Attribute( + key: 'userInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'userId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'teamInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'teamId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'roles', + type: ColumnType::String, + size: 128, + array: true, + ), + new Attribute( + key: 'invited', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), + new Attribute( + key: 'joined', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), + new Attribute( + key: 'confirm', + type: ColumnType::Boolean, + ), + new Attribute( + key: 'secret', + type: ColumnType::String, + size: 256, + filters: ['encrypt'], + ), + new Attribute( + key: 'search', + type: ColumnType::String, + size: 16384, + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_key_unique'), - 'type' => Database::INDEX_UNIQUE, - 'attributes' => ['teamInternalId', 'userInternalId'], - 'lengths' => [Database::LENGTH_KEY, Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC, Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_user'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['userInternalId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_team'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['teamInternalId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_search'), - 'type' => Database::INDEX_FULLTEXT, - 'attributes' => ['search'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => ID::custom('_key_userId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['userId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_teamId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['teamId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_invited'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['invited'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_joined'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['joined'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_confirm'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['confirm'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], + new Index( + key: '_key_unique', + type: IndexType::Unique, + attributes: ['teamInternalId', 'userInternalId'], + lengths: [255, 255], + orders: ['ASC', 'ASC'], + ), + new Index( + key: '_key_user', + type: IndexType::Key, + attributes: ['userInternalId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_team', + type: IndexType::Key, + attributes: ['teamInternalId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_search', + type: IndexType::Fulltext, + attributes: ['search'], + ), + new Index( + key: '_key_userId', + type: IndexType::Key, + attributes: ['userId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_teamId', + type: IndexType::Key, + attributes: ['teamId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_invited', + type: IndexType::Key, + attributes: ['invited'], + orders: ['ASC'], + ), + new Index( + key: '_key_joined', + type: IndexType::Key, + attributes: ['joined'], + orders: ['ASC'], + ), + new Index( + key: '_key_confirm', + type: IndexType::Key, + attributes: ['confirm'], + orders: ['ASC'], + ), ], ], - 'buckets' => [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('buckets'), + '$collection' => '_metadata', + '$id' => 'buckets', 'name' => 'Buckets', 'attributes' => [ - [ - '$id' => ID::custom('enabled'), - 'type' => Database::VAR_BOOLEAN, - 'signed' => true, - 'size' => 0, - 'format' => '', - 'filters' => [], - 'required' => true, - 'array' => false, - ], - [ - '$id' => ID::custom('name'), - 'type' => Database::VAR_STRING, - 'signed' => true, - 'size' => 128, - 'format' => '', - 'filters' => [], - 'required' => true, - 'array' => false, - ], - [ - '$id' => ID::custom('fileSecurity'), - 'type' => Database::VAR_BOOLEAN, - 'signed' => true, - 'size' => 1, - 'format' => '', - 'filters' => [], - 'required' => false, - 'array' => false, - ], - [ - '$id' => ID::custom('maximumFileSize'), - 'type' => Database::VAR_INTEGER, - 'signed' => false, - 'size' => 8, - 'format' => '', - 'filters' => [], - 'required' => true, - 'array' => false, - ], - [ - '$id' => ID::custom('allowedFileExtensions'), - 'type' => Database::VAR_STRING, - 'signed' => true, - 'size' => 64, - 'format' => '', - 'filters' => [], - 'required' => true, - 'array' => true, - ], - [ - '$id' => 'compression', - 'type' => Database::VAR_STRING, - 'signed' => true, - 'size' => 10, - 'format' => '', - 'filters' => [], - 'required' => true, - 'array' => false, - ], - [ - '$id' => ID::custom('encryption'), - 'type' => Database::VAR_BOOLEAN, - 'signed' => true, - 'size' => 0, - 'format' => '', - 'filters' => [], - 'required' => true, - 'array' => false, - ], - [ - '$id' => ID::custom('antivirus'), - 'type' => Database::VAR_BOOLEAN, - 'signed' => true, - 'size' => 0, - 'format' => '', - 'filters' => [], - 'required' => true, - 'array' => false, - ], - [ - '$id' => ID::custom('transformations'), - 'type' => Database::VAR_BOOLEAN, - 'signed' => true, - 'size' => 0, - 'format' => '', - 'filters' => [], - 'required' => false, - 'array' => false, - 'default' => true, - ], - [ - '$id' => ID::custom('search'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], + new Attribute( + key: 'enabled', + type: ColumnType::Boolean, + required: true, + ), + new Attribute( + key: 'name', + type: ColumnType::String, + size: 128, + required: true, + ), + new Attribute( + key: 'fileSecurity', + type: ColumnType::Boolean, + size: 1, + ), + new Attribute( + key: 'maximumFileSize', + type: ColumnType::Integer, + size: 8, + required: true, + signed: false, + ), + new Attribute( + key: 'allowedFileExtensions', + type: ColumnType::String, + size: 64, + required: true, + array: true, + ), + new Attribute( + key: 'compression', + type: ColumnType::String, + size: 10, + required: true, + ), + new Attribute( + key: 'encryption', + type: ColumnType::Boolean, + required: true, + ), + new Attribute( + key: 'antivirus', + type: ColumnType::Boolean, + required: true, + ), + new Attribute( + key: 'transformations', + type: ColumnType::Boolean, + default: true, + ), + new Attribute( + key: 'search', + type: ColumnType::String, + size: 16384, + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_key_search'), - 'type' => Database::INDEX_FULLTEXT, - 'attributes' => ['search'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => ID::custom('_key_enabled'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['enabled'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_name'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['name'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_fileSecurity'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['fileSecurity'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_maximumFileSize'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['maximumFileSize'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_encryption'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['encryption'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_antivirus'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['antivirus'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - ] + new Index( + key: '_key_search', + type: IndexType::Fulltext, + attributes: ['search'], + ), + new Index( + key: '_key_enabled', + type: IndexType::Key, + attributes: ['enabled'], + orders: ['ASC'], + ), + new Index( + key: '_key_name', + type: IndexType::Key, + attributes: ['name'], + orders: ['ASC'], + ), + new Index( + key: '_key_fileSecurity', + type: IndexType::Key, + attributes: ['fileSecurity'], + orders: ['ASC'], + ), + new Index( + key: '_key_maximumFileSize', + type: IndexType::Key, + attributes: ['maximumFileSize'], + orders: ['ASC'], + ), + new Index( + key: '_key_encryption', + type: IndexType::Key, + attributes: ['encryption'], + orders: ['ASC'], + ), + new Index( + key: '_key_antivirus', + type: IndexType::Key, + attributes: ['antivirus'], + orders: ['ASC'], + ), + ], ], - 'stats' => [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('stats'), + '$collection' => '_metadata', + '$id' => 'stats', 'name' => 'Stats', 'attributes' => [ - [ - '$id' => ID::custom('metric'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 255, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('region'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 255, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('value'), - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 8, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('time'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('period'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 4, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], + new Attribute( + key: 'metric', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'region', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'value', + type: ColumnType::Integer, + size: 8, + required: true, + ), + new Attribute( + key: 'time', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), + new Attribute( + key: 'period', + type: ColumnType::String, + size: 4, + required: true, + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_key_time'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['time'], - 'lengths' => [], - 'orders' => [Database::ORDER_DESC], - ], - [ - '$id' => ID::custom('_key_period_time'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['period', 'time'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_metric_period_time'), - 'type' => Database::INDEX_UNIQUE, - 'attributes' => ['metric', 'period', 'time'], - 'lengths' => [], - 'orders' => [Database::ORDER_DESC], - ], + new Index( + key: '_key_time', + type: IndexType::Key, + attributes: ['time'], + orders: ['DESC'], + ), + new Index( + key: '_key_period_time', + type: IndexType::Key, + attributes: ['period', 'time'], + orders: ['ASC'], + ), + new Index( + key: '_key_metric_period_time', + type: IndexType::Unique, + attributes: ['metric', 'period', 'time'], + orders: ['DESC'], + ), ], ], - 'providers' => [ - '$collection' => ID::custom(DATABASE::METADATA), - '$id' => ID::custom('providers'), + '$collection' => '_metadata', + '$id' => 'providers', 'name' => 'Providers', 'attributes' => [ - [ - '$id' => ID::custom('name'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('provider'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('type'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('enabled'), - 'type' => Database::VAR_BOOLEAN, - 'signed' => true, - 'size' => 0, - 'format' => '', - 'filters' => [], - 'required' => true, - 'default' => true, - 'array' => false, - ], - [ - '$id' => ID::custom('credentials'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => ['json', 'encrypt'], - ], - [ - '$id' => ID::custom('options'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => [], - 'array' => false, - 'filters' => ['json'], - ], - [ - '$id' => ID::custom('search'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 65535, - 'signed' => true, - 'required' => false, - 'default' => '', - 'array' => false, - 'filters' => ['providerSearch'], - ], + new Attribute( + key: 'name', + type: ColumnType::String, + size: 128, + required: true, + ), + new Attribute( + key: 'provider', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'type', + type: ColumnType::String, + size: 128, + required: true, + ), + new Attribute( + key: 'enabled', + type: ColumnType::Boolean, + required: true, + default: true, + ), + new Attribute( + key: 'credentials', + type: ColumnType::String, + size: 16384, + required: true, + filters: ['json', 'encrypt'], + ), + new Attribute( + key: 'options', + type: ColumnType::String, + size: 16384, + default: [], + filters: ['json'], + ), + new Attribute( + key: 'search', + type: ColumnType::String, + size: 65535, + default: '', + filters: ['providerSearch'], + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_key_provider'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['provider'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_type'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['type'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_enabled_type'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['enabled', 'type'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_search'), - 'type' => Database::INDEX_FULLTEXT, - 'attributes' => ['search'], - 'lengths' => [], - 'orders' => [], - ] + new Index( + key: '_key_provider', + type: IndexType::Key, + attributes: ['provider'], + orders: ['ASC'], + ), + new Index( + key: '_key_type', + type: IndexType::Key, + attributes: ['type'], + orders: ['ASC'], + ), + new Index( + key: '_key_enabled_type', + type: IndexType::Key, + attributes: ['enabled', 'type'], + orders: ['ASC'], + ), + new Index( + key: '_key_search', + type: IndexType::Fulltext, + attributes: ['search'], + ), ], ], - 'messages' => [ - '$collection' => ID::custom(DATABASE::METADATA), - '$id' => ID::custom('messages'), + '$collection' => '_metadata', + '$id' => 'messages', 'name' => 'Messages', 'attributes' => [ - [ - '$id' => ID::custom('providerType'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('status'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => 'processing', - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('data'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 65535, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => ['json'], - ], - [ - '$id' => ID::custom('topics'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 21845, - 'signed' => true, - 'required' => false, - 'default' => [], - 'array' => true, - 'filters' => [], - ], - [ - '$id' => ID::custom('users'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 21845, - 'signed' => true, - 'required' => false, - 'default' => [], - 'array' => true, - 'filters' => [], - ], - [ - '$id' => ID::custom('targets'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 21845, - 'signed' => true, - 'required' => false, - 'default' => [], - 'array' => true, - 'filters' => [], - ], - [ - '$id' => ID::custom('scheduledAt'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('scheduleInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('scheduleId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('deliveredAt'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('deliveryErrors'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 65535, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => true, - 'filters' => [], - ], - [ - '$id' => ID::custom('deliveredTotal'), - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => 0, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('search'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => '', - 'array' => false, - 'filters' => ['messageSearch'], - ], + new Attribute( + key: 'providerType', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'status', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + default: 'processing', + ), + new Attribute( + key: 'data', + type: ColumnType::String, + size: 65535, + required: true, + filters: ['json'], + ), + new Attribute( + key: 'topics', + type: ColumnType::String, + size: 21845, + default: [], + array: true, + ), + new Attribute( + key: 'users', + type: ColumnType::String, + size: 21845, + default: [], + array: true, + ), + new Attribute( + key: 'targets', + type: ColumnType::String, + size: 21845, + default: [], + array: true, + ), + new Attribute( + key: 'scheduledAt', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), + new Attribute( + key: 'scheduleInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'scheduleId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'deliveredAt', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), + new Attribute( + key: 'deliveryErrors', + type: ColumnType::String, + size: 65535, + array: true, + ), + new Attribute( + key: 'deliveredTotal', + type: ColumnType::Integer, + default: 0, + ), + new Attribute( + key: 'search', + type: ColumnType::String, + size: 16384, + default: '', + filters: ['messageSearch'], + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_key_search'), - 'type' => Database::INDEX_FULLTEXT, - 'attributes' => ['search'], - 'lengths' => [], - 'orders' => [], - ], + new Index( + key: '_key_search', + type: IndexType::Fulltext, + attributes: ['search'], + ), ], ], - 'topics' => [ - '$collection' => ID::custom(DATABASE::METADATA), - '$id' => ID::custom('topics'), + '$collection' => '_metadata', + '$id' => 'topics', 'name' => 'Topics', 'attributes' => [ - [ - '$id' => ID::custom('name'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('subscribe'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => true, - 'filters' => [], - ], - [ - '$id' => ID::custom('emailTotal'), - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => 0, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('smsTotal'), - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => 0, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('pushTotal'), - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => 0, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('targets'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['subQueryTopicTargets'], - ], - [ - '$id' => ID::custom('search'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => '', - 'array' => false, - 'filters' => ['topicSearch'], - ], + new Attribute( + key: 'name', + type: ColumnType::String, + size: 128, + required: true, + ), + new Attribute( + key: 'subscribe', + type: ColumnType::String, + size: 128, + array: true, + ), + new Attribute( + key: 'emailTotal', + type: ColumnType::Integer, + default: 0, + ), + new Attribute( + key: 'smsTotal', + type: ColumnType::Integer, + default: 0, + ), + new Attribute( + key: 'pushTotal', + type: ColumnType::Integer, + default: 0, + ), + new Attribute( + key: 'targets', + type: ColumnType::String, + size: 16384, + filters: ['subQueryTopicTargets'], + ), + new Attribute( + key: 'search', + type: ColumnType::String, + size: 16384, + default: '', + filters: ['topicSearch'], + ), ], - 'indexes' => [ - [ - '$id' => ID::custom('_key_search'), - 'type' => Database::INDEX_FULLTEXT, - 'attributes' => ['search'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ] + new Index( + key: '_key_search', + type: IndexType::Fulltext, + attributes: ['search'], + orders: ['ASC'], + ), ], ], - 'subscribers' => [ - '$collection' => ID::custom(DATABASE::METADATA), - '$id' => ID::custom('subscribers'), + '$collection' => '_metadata', + '$id' => 'subscribers', 'name' => 'Subscribers', 'attributes' => [ - [ - '$id' => ID::custom('targetId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('targetInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('userId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('userInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('topicId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('topicInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('providerType'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('search'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], + new Attribute( + key: 'targetId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'targetInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'userId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'userInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'topicId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'topicInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'providerType', + type: ColumnType::String, + size: 128, + required: true, + ), + new Attribute( + key: 'search', + type: ColumnType::String, + size: 16384, + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_key_targetId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['targetId'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => ID::custom('_key_targetInternalId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['targetInternalId'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => ID::custom('_key_userId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['userId'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => ID::custom('_key_userInternalId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['userInternalId'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => ID::custom('_key_topicId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['topicId'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => ID::custom('_key_topicInternalId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['topicInternalId'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => ID::custom('_unique_target_topic'), - 'type' => Database::INDEX_UNIQUE, - 'attributes' => ['targetInternalId', 'topicInternalId'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => ID::custom('_fulltext_search'), - 'type' => Database::INDEX_FULLTEXT, - 'attributes' => ['search'], - 'lengths' => [], - 'orders' => [], - ], + new Index( + key: '_key_targetId', + type: IndexType::Key, + attributes: ['targetId'], + ), + new Index( + key: '_key_targetInternalId', + type: IndexType::Key, + attributes: ['targetInternalId'], + ), + new Index( + key: '_key_userId', + type: IndexType::Key, + attributes: ['userId'], + ), + new Index( + key: '_key_userInternalId', + type: IndexType::Key, + attributes: ['userInternalId'], + ), + new Index( + key: '_key_topicId', + type: IndexType::Key, + attributes: ['topicId'], + ), + new Index( + key: '_key_topicInternalId', + type: IndexType::Key, + attributes: ['topicInternalId'], + ), + new Index( + key: '_unique_target_topic', + type: IndexType::Unique, + attributes: ['targetInternalId', 'topicInternalId'], + ), + new Index( + key: '_fulltext_search', + type: IndexType::Fulltext, + attributes: ['search'], + ), ], ], - 'targets' => [ - '$collection' => ID::custom(DATABASE::METADATA), - '$id' => ID::custom('targets'), + '$collection' => '_metadata', + '$id' => 'targets', 'name' => 'Targets', 'attributes' => [ - [ - '$id' => ID::custom('userId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('userInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('sessionId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('sessionInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('providerType'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('providerId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('providerInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('identifier'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('name'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('expired'), - 'type' => Database::VAR_BOOLEAN, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => false, - 'array' => false, - 'filters' => [], - ], + new Attribute( + key: 'userId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'userInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'sessionId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'sessionInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'providerType', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'providerId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'providerInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'identifier', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'name', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'expired', + type: ColumnType::Boolean, + default: false, + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_key_userId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['userId'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_userInternalId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['userInternalId'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_providerId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['providerId'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => ID::custom('_key_providerInternalId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['providerInternalId'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => ID::custom('_key_identifier'), - 'type' => Database::INDEX_UNIQUE, - 'attributes' => ['identifier'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => ID::custom('_key_expired'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['expired'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => ID::custom('_key_session_internal_id'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['sessionInternalId'], - 'lengths' => [], - 'orders' => [], - ], + new Index( + key: '_key_userId', + type: IndexType::Key, + attributes: ['userId'], + orders: ['ASC'], + ), + new Index( + key: '_key_userInternalId', + type: IndexType::Key, + attributes: ['userInternalId'], + orders: ['ASC'], + ), + new Index( + key: '_key_providerId', + type: IndexType::Key, + attributes: ['providerId'], + ), + new Index( + key: '_key_providerInternalId', + type: IndexType::Key, + attributes: ['providerInternalId'], + ), + new Index( + key: '_key_identifier', + type: IndexType::Unique, + attributes: ['identifier'], + ), + new Index( + key: '_key_expired', + type: IndexType::Key, + attributes: ['expired'], + ), + new Index( + key: '_key_session_internal_id', + type: IndexType::Key, + attributes: ['sessionInternalId'], + ), ], ], - - // note that this is not required for console & projects. 'files' => [ - '$collection' => ID::custom('buckets'), - '$id' => ID::custom('files'), + '$collection' => 'buckets', + '$id' => 'files', '$name' => 'Files', 'attributes' => [ - [ - 'array' => false, - '$id' => ID::custom('bucketId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'filters' => [], - ], - [ - 'array' => false, - '$id' => ID::custom('bucketInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'filters' => [], - ], - [ - '$id' => ID::custom('name'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2048, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('path'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2048, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('signature'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2048, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('mimeType'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 255, // https://tools.ietf.org/html/rfc4288#section-4.2 - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('metadata'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 75000, // https://tools.ietf.org/html/rfc4288#section-4.2 - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['json'], - ], - [ - '$id' => ID::custom('sizeOriginal'), - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 8, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('sizeActual'), - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 8, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('algorithm'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 255, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('comment'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2048, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('openSSLVersion'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 64, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('openSSLCipher'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 64, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('openSSLTag'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2048, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('openSSLIV'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2048, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('chunksTotal'), - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('chunksUploaded'), - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'transformedAt', - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('search'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], + new Attribute( + key: 'bucketId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'bucketInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'name', + type: ColumnType::String, + size: 2048, + ), + new Attribute( + key: 'path', + type: ColumnType::String, + size: 2048, + ), + new Attribute( + key: 'signature', + type: ColumnType::String, + size: 2048, + ), + new Attribute( + key: 'mimeType', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'metadata', + type: ColumnType::String, + size: 75000, + filters: ['json'], + ), + new Attribute( + key: 'sizeOriginal', + type: ColumnType::Integer, + size: 8, + signed: false, + ), + new Attribute( + key: 'sizeActual', + type: ColumnType::Integer, + size: 8, + signed: false, + ), + new Attribute( + key: 'algorithm', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'comment', + type: ColumnType::String, + size: 2048, + ), + new Attribute( + key: 'openSSLVersion', + type: ColumnType::String, + size: 64, + ), + new Attribute( + key: 'openSSLCipher', + type: ColumnType::String, + size: 64, + ), + new Attribute( + key: 'openSSLTag', + type: ColumnType::String, + size: 2048, + ), + new Attribute( + key: 'openSSLIV', + type: ColumnType::String, + size: 2048, + ), + new Attribute( + key: 'chunksTotal', + type: ColumnType::Integer, + signed: false, + ), + new Attribute( + key: 'chunksUploaded', + type: ColumnType::Integer, + signed: false, + ), + new Attribute( + key: 'transformedAt', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), + new Attribute( + key: 'search', + type: ColumnType::String, + size: 16384, + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_key_search'), - 'type' => Database::INDEX_FULLTEXT, - 'attributes' => ['search'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => ID::custom('_key_bucket'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['bucketId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_name'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['name'], - 'lengths' => [256], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_signature'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['signature'], - 'lengths' => [256], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_mimeType'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['mimeType'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_sizeOriginal'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['sizeOriginal'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_chunksTotal'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['chunksTotal'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_chunksUploaded'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['chunksUploaded'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_transformedAt'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['transformedAt'], - 'lengths' => [], - 'orders' => [], - ] - ] + new Index( + key: '_key_search', + type: IndexType::Fulltext, + attributes: ['search'], + ), + new Index( + key: '_key_bucket', + type: IndexType::Key, + attributes: ['bucketId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_name', + type: IndexType::Key, + attributes: ['name'], + lengths: [256], + orders: ['ASC'], + ), + new Index( + key: '_key_signature', + type: IndexType::Key, + attributes: ['signature'], + lengths: [256], + orders: ['ASC'], + ), + new Index( + key: '_key_mimeType', + type: IndexType::Key, + attributes: ['mimeType'], + orders: ['ASC'], + ), + new Index( + key: '_key_sizeOriginal', + type: IndexType::Key, + attributes: ['sizeOriginal'], + orders: ['ASC'], + ), + new Index( + key: '_key_chunksTotal', + type: IndexType::Key, + attributes: ['chunksTotal'], + orders: ['ASC'], + ), + new Index( + key: '_key_chunksUploaded', + type: IndexType::Key, + attributes: ['chunksUploaded'], + orders: ['ASC'], + ), + new Index( + key: '_key_transformedAt', + type: IndexType::Key, + attributes: ['transformedAt'], + ), + ], ], ]; diff --git a/app/config/collections/databases.php b/app/config/collections/databases.php index 995caecb7f..4687599237 100644 --- a/app/config/collections/databases.php +++ b/app/config/collections/databases.php @@ -1,126 +1,88 @@ [ - '$collection' => ID::custom('databases'), - '$id' => ID::custom('collections'), + '$collection' => 'databases', + '$id' => 'collections', 'name' => 'Collections', 'attributes' => [ - [ - '$id' => ID::custom('databaseInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('databaseId'), - 'type' => Database::VAR_STRING, - 'signed' => true, - 'size' => Database::LENGTH_KEY, - 'format' => '', - 'filters' => [], - 'required' => true, - 'default' => null, - 'array' => false, - ], - [ - '$id' => ID::custom('name'), - 'type' => Database::VAR_STRING, - 'size' => 256, - 'required' => true, - 'signed' => true, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('enabled'), - 'type' => Database::VAR_BOOLEAN, - 'signed' => true, - 'size' => 0, - 'format' => '', - 'filters' => [], - 'required' => true, - 'default' => null, - 'array' => false, - ], - [ - '$id' => ID::custom('documentSecurity'), - 'type' => Database::VAR_BOOLEAN, - 'signed' => true, - 'size' => 0, - 'format' => '', - 'filters' => [], - 'required' => true, - 'default' => null, - 'array' => false, - ], - [ - '$id' => ID::custom('attributes'), - 'type' => Database::VAR_STRING, - 'size' => 1000000, - 'required' => false, - 'signed' => true, - 'array' => false, - 'filters' => ['subQueryAttributes'], - ], - [ - '$id' => ID::custom('indexes'), - 'type' => Database::VAR_STRING, - 'size' => 1000000, - 'required' => false, - 'signed' => true, - 'array' => false, - 'filters' => ['subQueryIndexes'], - ], - [ - '$id' => ID::custom('search'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], + new Attribute( + key: 'databaseInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'databaseId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'name', + type: ColumnType::String, + size: 256, + required: true, + ), + new Attribute( + key: 'enabled', + type: ColumnType::Boolean, + required: true, + ), + new Attribute( + key: 'documentSecurity', + type: ColumnType::Boolean, + required: true, + ), + new Attribute( + key: 'attributes', + type: ColumnType::String, + size: 1000000, + filters: ['subQueryAttributes'], + ), + new Attribute( + key: 'indexes', + type: ColumnType::String, + size: 1000000, + filters: ['subQueryIndexes'], + ), + new Attribute( + key: 'search', + type: ColumnType::String, + size: 16384, + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_fulltext_search'), - 'type' => Database::INDEX_FULLTEXT, - 'attributes' => ['search'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => ID::custom('_key_name'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['name'], - 'lengths' => [256], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_enabled'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['enabled'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_documentSecurity'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['documentSecurity'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], + new Index( + key: '_fulltext_search', + type: IndexType::Fulltext, + attributes: ['search'], + ), + new Index( + key: '_key_name', + type: IndexType::Key, + attributes: ['name'], + lengths: [256], + orders: ['ASC'], + ), + new Index( + key: '_key_enabled', + type: IndexType::Key, + attributes: ['enabled'], + orders: ['ASC'], + ), + new Index( + key: '_key_documentSecurity', + type: IndexType::Key, + attributes: ['documentSecurity'], + orders: ['ASC'], + ), ], - ] + ], ]; diff --git a/app/config/collections/logs.php b/app/config/collections/logs.php index 069dcf5a4b..9b97d23fcd 100644 --- a/app/config/collections/logs.php +++ b/app/config/collections/logs.php @@ -1,94 +1,67 @@ ID::custom(Database::METADATA), - '$id' => ID::custom('stats'), - 'name' => 'stats', - 'attributes' => [ - [ - '$id' => ID::custom('metric'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 255, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], +return [ + 'stats' => [ + '$collection' => '_metadata', + '$id' => 'stats', + 'name' => 'stats', + 'attributes' => [ + new Attribute( + key: 'metric', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'region', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'value', + type: ColumnType::Integer, + size: 8, + required: true, + ), + new Attribute( + key: 'time', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), + new Attribute( + key: 'period', + type: ColumnType::String, + size: 4, + required: true, + ), ], - [ - '$id' => ID::custom('region'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 255, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('value'), - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 8, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('time'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('period'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 4, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - ], - 'indexes' => [ - [ - '$id' => ID::custom('_key_time'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['time'], - 'lengths' => [], - 'orders' => [Database::ORDER_DESC], - ], - [ - '$id' => ID::custom('_key_period_time'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['period', 'time'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_metric_period_time'), - 'type' => Database::INDEX_UNIQUE, - 'attributes' => ['metric', 'period', 'time'], - 'lengths' => [], - 'orders' => [Database::ORDER_DESC], + 'indexes' => [ + new Index( + key: '_key_time', + type: IndexType::Key, + attributes: ['time'], + orders: ['DESC'], + ), + new Index( + key: '_key_period_time', + type: IndexType::Key, + attributes: ['period', 'time'], + orders: ['ASC'], + ), + new Index( + key: '_key_metric_period_time', + type: IndexType::Unique, + attributes: ['metric', 'period', 'time'], + orders: ['DESC'], + ), ], ], ]; - -return $logsCollection; diff --git a/app/config/collections/platform.php b/app/config/collections/platform.php index 84964ac96a..cd7e48a7bc 100644 --- a/app/config/collections/platform.php +++ b/app/config/collections/platform.php @@ -1,1966 +1,1227 @@ [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('projects'), + '$collection' => '_metadata', + '$id' => 'projects', 'name' => 'Projects', 'attributes' => [ - [ - '$id' => ID::custom('teamInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('teamId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('name'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('region'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('description'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('database'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('logo'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('url'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('version'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('legalName'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('legalCountry'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('legalState'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('legalCity'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('legalAddress'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('legalTaxId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'accessedAt', - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('services'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => [], - 'array' => false, - 'filters' => ['json'], - ], - [ - '$id' => ID::custom('apis'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => [], - 'array' => false, - 'filters' => ['json'], - ], - [ - '$id' => ID::custom('smtp'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => [], - 'array' => false, - 'filters' => ['json', 'encrypt'], - ], - [ - '$id' => ID::custom('templates'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 1_000_000, // TODO make sure size fits - 'signed' => true, - 'required' => false, - 'default' => [], - 'array' => false, - 'filters' => ['json'], - ], - [ - '$id' => ID::custom('auths'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => [], - 'array' => false, - 'filters' => ['json'], - ], - [ - '$id' => ID::custom('oAuthProviders'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => [], - 'array' => false, - 'filters' => ['json', 'encrypt'], - ], - [ - '$id' => ID::custom('platforms'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['subQueryPlatforms'], - ], - [ - '$id' => ID::custom('webhooks'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['subQueryWebhooks'], - ], - [ - '$id' => ID::custom('keys'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['subQueryKeys'], - ], - [ - '$id' => ID::custom('devKeys'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['subQueryDevKeys'], - ], - [ - '$id' => ID::custom('search'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('pingCount'), - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => 0, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('pingedAt'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('labels'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => true, - 'required' => false, - 'default' => [], - 'array' => true, - 'filters' => [], - ], - [ - '$id' => 'status', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 100, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], + new Attribute( + key: 'teamInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'teamId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'name', + type: ColumnType::String, + size: 128, + ), + new Attribute( + key: 'region', + type: ColumnType::String, + size: 128, + ), + new Attribute( + key: 'description', + type: ColumnType::String, + size: 256, + ), + new Attribute( + key: 'database', + type: ColumnType::String, + size: 256, + required: true, + ), + new Attribute( + key: 'logo', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'url', + type: ColumnType::String, + size: 16384, + ), + new Attribute( + key: 'version', + type: ColumnType::String, + size: 16, + ), + new Attribute( + key: 'legalName', + type: ColumnType::String, + size: 256, + ), + new Attribute( + key: 'legalCountry', + type: ColumnType::String, + size: 256, + ), + new Attribute( + key: 'legalState', + type: ColumnType::String, + size: 256, + ), + new Attribute( + key: 'legalCity', + type: ColumnType::String, + size: 256, + ), + new Attribute( + key: 'legalAddress', + type: ColumnType::String, + size: 256, + ), + new Attribute( + key: 'legalTaxId', + type: ColumnType::String, + size: 256, + ), + new Attribute( + key: 'accessedAt', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), + new Attribute( + key: 'services', + type: ColumnType::String, + size: 16384, + default: [], + filters: ['json'], + ), + new Attribute( + key: 'apis', + type: ColumnType::String, + size: 16384, + default: [], + filters: ['json'], + ), + new Attribute( + key: 'smtp', + type: ColumnType::String, + size: 16384, + default: [], + filters: ['json', 'encrypt'], + ), + new Attribute( + key: 'templates', + type: ColumnType::String, + size: 1000000, + default: [], + filters: ['json'], + ), + new Attribute( + key: 'auths', + type: ColumnType::String, + size: 16384, + default: [], + filters: ['json'], + ), + new Attribute( + key: 'oAuthProviders', + type: ColumnType::String, + size: 16384, + default: [], + filters: ['json', 'encrypt'], + ), + new Attribute( + key: 'platforms', + type: ColumnType::String, + size: 16384, + filters: ['subQueryPlatforms'], + ), + new Attribute( + key: 'webhooks', + type: ColumnType::String, + size: 16384, + filters: ['subQueryWebhooks'], + ), + new Attribute( + key: 'keys', + type: ColumnType::String, + size: 16384, + filters: ['subQueryKeys'], + ), + new Attribute( + key: 'devKeys', + type: ColumnType::String, + size: 16384, + filters: ['subQueryDevKeys'], + ), + new Attribute( + key: 'search', + type: ColumnType::String, + size: 16384, + ), + new Attribute( + key: 'pingCount', + type: ColumnType::Integer, + default: 0, + signed: false, + ), + new Attribute( + key: 'pingedAt', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), + new Attribute( + key: 'labels', + type: ColumnType::String, + size: 128, + default: [], + array: true, + ), + new Attribute( + key: 'status', + type: ColumnType::String, + size: 100, + signed: false, + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_key_search'), - 'type' => Database::INDEX_FULLTEXT, - 'attributes' => ['search'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => ID::custom('_key_name'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['name'], - 'lengths' => [128], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_team'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['teamId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_pingCount'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['pingCount'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => ID::custom('_key_pingedAt'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['pingedAt'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => ID::custom('_key_database'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['database'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => ID::custom('_key_region_accessed_at'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['region', 'accessedAt'], - 'lengths' => [], - 'orders' => [], - ], + new Index( + key: '_key_search', + type: IndexType::Fulltext, + attributes: ['search'], + ), + new Index( + key: '_key_name', + type: IndexType::Key, + attributes: ['name'], + lengths: [128], + orders: ['ASC'], + ), + new Index( + key: '_key_team', + type: IndexType::Key, + attributes: ['teamId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_pingCount', + type: IndexType::Key, + attributes: ['pingCount'], + ), + new Index( + key: '_key_pingedAt', + type: IndexType::Key, + attributes: ['pingedAt'], + ), + new Index( + key: '_key_database', + type: IndexType::Key, + attributes: ['database'], + ), + new Index( + key: '_key_region_accessed_at', + type: IndexType::Key, + attributes: ['region', 'accessedAt'], + ), ], ], - 'schedules' => [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('schedules'), + '$collection' => '_metadata', + '$id' => 'schedules', 'name' => 'schedules', 'attributes' => [ - [ - '$id' => ID::custom('resourceType'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 100, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('resourceInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('resourceId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('resourceUpdatedAt'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('projectId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('schedule'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 100, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('data'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 65535, - 'signed' => true, - 'required' => false, - 'default' => new \stdClass(), - 'array' => false, - 'filters' => ['json', 'encrypt'], - ], - [ - '$id' => ID::custom('active'), - 'type' => Database::VAR_BOOLEAN, - 'signed' => true, - 'size' => 0, - 'format' => '', - 'filters' => [], - 'required' => false, - 'default' => null, - 'array' => false, - ], - [ - '$id' => ID::custom('region'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 10, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], + new Attribute( + key: 'resourceType', + type: ColumnType::String, + size: 100, + ), + new Attribute( + key: 'resourceInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'resourceId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'resourceUpdatedAt', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), + new Attribute( + key: 'projectId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'schedule', + type: ColumnType::String, + size: 100, + ), + new Attribute( + key: 'data', + type: ColumnType::String, + size: 65535, + default: (object) array( + ), + filters: ['json', 'encrypt'], + ), + new Attribute( + key: 'active', + type: ColumnType::Boolean, + ), + new Attribute( + key: 'region', + type: ColumnType::String, + size: 10, + required: true, + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_key_region_resourceType_resourceUpdatedAt'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['region', 'resourceType', 'resourceUpdatedAt'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => ID::custom('_key_region_resourceType_projectId_resourceId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['region', 'resourceType', 'projectId', 'resourceId'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => ID::custom('_key_project_id_region'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['projectId', 'region'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => ID::custom('_key_region_rt_active'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['region', 'resourceType', 'active'], - 'lengths' => [], - 'orders' => [], - ], + new Index( + key: '_key_region_resourceType_resourceUpdatedAt', + type: IndexType::Key, + attributes: ['region', 'resourceType', 'resourceUpdatedAt'], + ), + new Index( + key: '_key_region_resourceType_projectId_resourceId', + type: IndexType::Key, + attributes: ['region', 'resourceType', 'projectId', 'resourceId'], + ), + new Index( + key: '_key_project_id_region', + type: IndexType::Key, + attributes: ['projectId', 'region'], + ), + new Index( + key: '_key_region_rt_active', + type: IndexType::Key, + attributes: ['region', 'resourceType', 'active'], + ), ], ], - 'platforms' => [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('platforms'), + '$collection' => '_metadata', + '$id' => 'platforms', 'name' => 'platforms', 'attributes' => [ - [ - '$id' => ID::custom('projectInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('projectId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('type'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('name'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('key'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('store'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('hostname'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ] + new Attribute( + key: 'projectInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'projectId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'type', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'name', + type: ColumnType::String, + size: 256, + required: true, + ), + new Attribute( + key: 'key', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'store', + type: ColumnType::String, + size: 256, + ), + new Attribute( + key: 'hostname', + type: ColumnType::String, + size: 256, + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_key_project'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['projectInternalId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], + new Index( + key: '_key_project', + type: IndexType::Key, + attributes: ['projectInternalId'], + lengths: [255], + orders: ['ASC'], + ), ], ], - 'keys' => [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('keys'), + '$collection' => '_metadata', + '$id' => 'keys', 'name' => 'keys', 'attributes' => [ - [ - '$id' => ID::custom('resourceType'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('resourceId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('resourceInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('name'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('scopes'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => true, - 'filters' => [], - ], - [ - '$id' => ID::custom('secret'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 512, // var_dump of \bin2hex(\random_bytes(128)) => string(256) doubling for encryption - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => ['encrypt'], - ], - [ - '$id' => ID::custom('expire'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('accessedAt'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('sdks'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => true, - 'filters' => [], - ], + new Attribute( + key: 'resourceType', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'resourceId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'resourceInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'name', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'scopes', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + array: true, + ), + new Attribute( + key: 'secret', + type: ColumnType::String, + size: 512, + required: true, + filters: ['encrypt'], + ), + new Attribute( + key: 'expire', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), + new Attribute( + key: 'accessedAt', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), + new Attribute( + key: 'sdks', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + array: true, + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_key_resource'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['resourceType', 'resourceInternalId'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => ID::custom('_key_accessedAt'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['accessedAt'], - 'lengths' => [], - 'orders' => [], - ], + new Index( + key: '_key_resource', + type: IndexType::Key, + attributes: ['resourceType', 'resourceInternalId'], + ), + new Index( + key: '_key_accessedAt', + type: IndexType::Key, + attributes: ['accessedAt'], + ), ], ], - 'devKeys' => [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('devKeys'), + '$collection' => '_metadata', + '$id' => 'devKeys', 'name' => 'Dev keys', 'attributes' => [ - [ - '$id' => ID::custom('projectInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('projectId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => 0, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('name'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('secret'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 512, // var_dump of \bin2hex(\random_bytes(128)) => string(256) doubling for encryption - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => ['encrypt'], - ], - [ - '$id' => ID::custom('expire'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('accessedAt'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('sdks'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => true, - 'filters' => [], - ], + new Attribute( + key: 'projectInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'projectId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + default: 0, + ), + new Attribute( + key: 'name', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'secret', + type: ColumnType::String, + size: 512, + required: true, + filters: ['encrypt'], + ), + new Attribute( + key: 'expire', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), + new Attribute( + key: 'accessedAt', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), + new Attribute( + key: 'sdks', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + array: true, + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_key_project'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['projectInternalId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => '_key_accessedAt', - 'type' => Database::INDEX_KEY, - 'attributes' => ['accessedAt'], - 'lengths' => [], - 'orders' => [], - ], + new Index( + key: '_key_project', + type: IndexType::Key, + attributes: ['projectInternalId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_accessedAt', + type: IndexType::Key, + attributes: ['accessedAt'], + ), ], ], - 'webhooks' => [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('webhooks'), + '$collection' => '_metadata', + '$id' => 'webhooks', 'name' => 'webhooks', 'attributes' => [ - [ - '$id' => ID::custom('projectInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('projectId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('name'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('url'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('httpUser'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('httpPass'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, // TODO will the length suffice after encryption? - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['encrypt'], - ], - [ - '$id' => ID::custom('security'), - 'type' => Database::VAR_BOOLEAN, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('events'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => true, - 'filters' => [], - ], - [ - '$id' => ID::custom('signatureKey'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2048, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('enabled'), - 'type' => Database::VAR_BOOLEAN, - 'signed' => true, - 'size' => 0, - 'format' => '', - 'filters' => [], - 'required' => false, - 'default' => true, - 'array' => false, - ], - [ - '$id' => ID::custom('logs'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 1000000, - 'signed' => true, - 'required' => false, - 'default' => '', - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('attempts'), - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => 0, - 'array' => false, - 'filters' => [], - ], + new Attribute( + key: 'projectInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'projectId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'name', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'url', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'httpUser', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'httpPass', + type: ColumnType::String, + size: Database::LENGTH_KEY, + filters: ['encrypt'], + ), + new Attribute( + key: 'security', + type: ColumnType::Boolean, + required: true, + ), + new Attribute( + key: 'events', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + array: true, + ), + new Attribute( + key: 'signatureKey', + type: ColumnType::String, + size: 2048, + ), + new Attribute( + key: 'enabled', + type: ColumnType::Boolean, + default: true, + ), + new Attribute( + key: 'logs', + type: ColumnType::String, + size: 1000000, + default: '', + ), + new Attribute( + key: 'attempts', + type: ColumnType::Integer, + default: 0, + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_key_project'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['projectInternalId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ] + new Index( + key: '_key_project', + type: IndexType::Key, + attributes: ['projectInternalId'], + lengths: [255], + orders: ['ASC'], + ), ], ], - 'certificates' => [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('certificates'), + '$collection' => '_metadata', + '$id' => 'certificates', 'name' => 'Certificates', 'attributes' => [ - [ - '$id' => ID::custom('domain'), - 'type' => Database::VAR_STRING, - 'format' => '', - // The maximum total length of a domain name or number is 255 characters. - // https://datatracker.ietf.org/doc/html/rfc2821#section-4.5.3.1 - // https://datatracker.ietf.org/doc/html/rfc5321#section-4.5.3.1.2 - 'size' => 255, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('issueDate'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('renewDate'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('attempts'), - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('logs'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 1000000, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('updated'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], + new Attribute( + key: 'domain', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'issueDate', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), + new Attribute( + key: 'renewDate', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), + new Attribute( + key: 'attempts', + type: ColumnType::Integer, + ), + new Attribute( + key: 'logs', + type: ColumnType::String, + size: 1000000, + ), + new Attribute( + key: 'updated', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_key_domain'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['domain'], - 'lengths' => [255], - 'orders' => [Database::ORDER_ASC], - ], + new Index( + key: '_key_domain', + type: IndexType::Key, + attributes: ['domain'], + lengths: [255], + orders: ['ASC'], + ), ], ], - 'realtime' => [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('realtime'), + '$collection' => '_metadata', + '$id' => 'realtime', 'name' => 'Realtime Connections', 'attributes' => [ - [ - '$id' => ID::custom('container'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('timestamp'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('value'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], //TODO: use json filter - ] + new Attribute( + key: 'container', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'timestamp', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), + new Attribute( + key: 'value', + type: ColumnType::String, + size: 16384, + required: true, + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_key_timestamp'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['timestamp'], - 'lengths' => [], - 'orders' => [Database::ORDER_DESC], - ], - ] + new Index( + key: '_key_timestamp', + type: IndexType::Key, + attributes: ['timestamp'], + orders: ['DESC'], + ), + ], ], - 'rules' => [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('rules'), + '$collection' => '_metadata', + '$id' => 'rules', 'name' => 'Rules', 'attributes' => [ - [ - '$id' => ID::custom('projectId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('projectInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('domain'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('type'), // 'api', 'redirect', 'deployment' (site or function) - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 32, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('trigger'), // 'manual', 'deployment', '' (empty) - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 32, - 'signed' => true, - 'required' => false, - 'default' => '', - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('redirectUrl'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2048, - 'signed' => true, - 'required' => false, - 'default' => '', - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('redirectStatusCode'), - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('deploymentResourceType'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 32, - 'signed' => true, - 'required' => false, - 'default' => '', - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('deploymentId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => '', - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('deploymentInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => '', - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('deploymentResourceId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => '', - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('deploymentResourceInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => '', - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('deploymentVcsProviderBranch'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => '', - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('status'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('certificateId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('search'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('owner'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16, - 'signed' => true, - 'required' => false, - 'default' => '', // "Appwrite" or empty string - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('region'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('logs'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 1000000, - 'signed' => true, - 'required' => false, - 'default' => '', - 'array' => false, - 'filters' => [], - ], + new Attribute( + key: 'projectId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'projectInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'domain', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'type', + type: ColumnType::String, + size: 32, + ), + new Attribute( + key: 'trigger', + type: ColumnType::String, + size: 32, + default: '', + ), + new Attribute( + key: 'redirectUrl', + type: ColumnType::String, + size: 2048, + default: '', + ), + new Attribute( + key: 'redirectStatusCode', + type: ColumnType::Integer, + ), + new Attribute( + key: 'deploymentResourceType', + type: ColumnType::String, + size: 32, + default: '', + ), + new Attribute( + key: 'deploymentId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + default: '', + ), + new Attribute( + key: 'deploymentInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + default: '', + ), + new Attribute( + key: 'deploymentResourceId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + default: '', + ), + new Attribute( + key: 'deploymentResourceInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + default: '', + ), + new Attribute( + key: 'deploymentVcsProviderBranch', + type: ColumnType::String, + size: Database::LENGTH_KEY, + default: '', + ), + new Attribute( + key: 'status', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'certificateId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'search', + type: ColumnType::String, + size: 16384, + ), + new Attribute( + key: 'owner', + type: ColumnType::String, + size: 16, + default: '', + ), + new Attribute( + key: 'region', + type: ColumnType::String, + size: 16, + required: true, + ), + new Attribute( + key: 'logs', + type: ColumnType::String, + size: 1000000, + default: '', + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_key_search'), - 'type' => Database::INDEX_FULLTEXT, - 'attributes' => ['search'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => ID::custom('_key_domain'), - 'type' => Database::INDEX_UNIQUE, - 'attributes' => ['domain'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_projectInternalId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['projectInternalId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_projectId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['projectId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => '_key_type', - 'type' => Database::INDEX_KEY, - 'attributes' => ['type'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => '_key_trigger', - 'type' => Database::INDEX_KEY, - 'attributes' => ['trigger'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => '_key_deploymentResourceType', - 'type' => Database::INDEX_KEY, - 'attributes' => ['deploymentResourceType'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => '_key_deploymentResourceId', - 'type' => Database::INDEX_KEY, - 'attributes' => ['deploymentResourceId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => '_key_deploymentResourceInternalId', - 'type' => Database::INDEX_KEY, - 'attributes' => ['deploymentResourceInternalId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => '_key_deploymentId', - 'type' => Database::INDEX_KEY, - 'attributes' => ['deploymentId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => '_key_deploymentInternalId', - 'type' => Database::INDEX_KEY, - 'attributes' => ['deploymentInternalId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => '_key_deploymentVcsProviderBranch', - 'type' => Database::INDEX_KEY, - 'attributes' => ['deploymentVcsProviderBranch'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_owner'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['owner'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_piid_diid_drt'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['projectInternalId', 'deploymentInternalId', 'deploymentResourceType'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => '_key_region_status_createdAt', - 'type' => Database::INDEX_KEY, - 'attributes' => ['region', 'status', '$createdAt'], - 'lengths' => [], - 'orders' => [], - ], + new Index( + key: '_key_search', + type: IndexType::Fulltext, + attributes: ['search'], + ), + new Index( + key: '_key_domain', + type: IndexType::Unique, + attributes: ['domain'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_projectInternalId', + type: IndexType::Key, + attributes: ['projectInternalId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_projectId', + type: IndexType::Key, + attributes: ['projectId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_type', + type: IndexType::Key, + attributes: ['type'], + orders: ['ASC'], + ), + new Index( + key: '_key_trigger', + type: IndexType::Key, + attributes: ['trigger'], + orders: ['ASC'], + ), + new Index( + key: '_key_deploymentResourceType', + type: IndexType::Key, + attributes: ['deploymentResourceType'], + orders: ['ASC'], + ), + new Index( + key: '_key_deploymentResourceId', + type: IndexType::Key, + attributes: ['deploymentResourceId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_deploymentResourceInternalId', + type: IndexType::Key, + attributes: ['deploymentResourceInternalId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_deploymentId', + type: IndexType::Key, + attributes: ['deploymentId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_deploymentInternalId', + type: IndexType::Key, + attributes: ['deploymentInternalId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_deploymentVcsProviderBranch', + type: IndexType::Key, + attributes: ['deploymentVcsProviderBranch'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_owner', + type: IndexType::Key, + attributes: ['owner'], + orders: ['ASC'], + ), + new Index( + key: '_key_piid_diid_drt', + type: IndexType::Key, + attributes: ['projectInternalId', 'deploymentInternalId', 'deploymentResourceType'], + ), + new Index( + key: '_key_region_status_createdAt', + type: IndexType::Key, + attributes: ['region', 'status', '$createdAt'], + ), ], ], - 'installations' => [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('installations'), + '$collection' => '_metadata', + '$id' => 'installations', 'name' => 'installations', 'attributes' => [ - [ - '$id' => ID::custom('projectId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('projectInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('providerInstallationId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('organization'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('provider'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('personal'), - 'type' => Database::VAR_BOOLEAN, - 'signed' => true, - 'size' => 0, - 'format' => '', - 'filters' => [], - 'required' => false, - 'default' => false, - 'array' => false, - ], - [ - '$id' => ID::custom('personalAccessToken'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['encrypt'], - ], - [ - '$id' => ID::custom('personalAccessTokenExpiry'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('personalRefreshToken'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['encrypt'], - ], + new Attribute( + key: 'projectId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'projectInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'providerInstallationId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'organization', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'provider', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'personal', + type: ColumnType::Boolean, + default: false, + ), + new Attribute( + key: 'personalAccessToken', + type: ColumnType::String, + size: 256, + filters: ['encrypt'], + ), + new Attribute( + key: 'personalAccessTokenExpiry', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), + new Attribute( + key: 'personalRefreshToken', + type: ColumnType::String, + size: 256, + filters: ['encrypt'], + ), ], 'indexes' => [ - - [ - '$id' => ID::custom('_key_projectInternalId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['projectInternalId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_projectId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['projectId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_providerInstallationId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['providerInstallationId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], + new Index( + key: '_key_projectInternalId', + type: IndexType::Key, + attributes: ['projectInternalId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_projectId', + type: IndexType::Key, + attributes: ['projectId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_providerInstallationId', + type: IndexType::Key, + attributes: ['providerInstallationId'], + lengths: [255], + orders: ['ASC'], + ), ], ], - 'repositories' => [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('repositories'), + '$collection' => '_metadata', + '$id' => 'repositories', 'name' => 'repositories', 'attributes' => [ - [ - '$id' => ID::custom('installationId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [] - ], - [ - '$id' => ID::custom('installationInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('projectId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [] - ], - [ - '$id' => ID::custom('projectInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('providerRepositoryId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [] - ], - [ - '$id' => ID::custom('resourceId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('resourceInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('resourceType'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [] - ], - [ - '$id' => ID::custom('providerPullRequestIds'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => true, - 'filters' => [], - ], + new Attribute( + key: 'installationId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'installationInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'projectId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'projectInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'providerRepositoryId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'resourceId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'resourceInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'resourceType', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'providerPullRequestIds', + type: ColumnType::String, + size: 128, + array: true, + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_key_installationId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['installationId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_installationInternalId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['installationInternalId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_projectInternalId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['projectInternalId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_projectId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['projectId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_providerRepositoryId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['providerRepositoryId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_resourceId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['resourceId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => '_key_resourceInternalId', - 'type' => Database::INDEX_KEY, - 'attributes' => ['resourceInternalId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_resourceType'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['resourceType'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_piid_riid_rt'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['projectInternalId', 'resourceInternalId', 'resourceType'], - 'lengths' => [], - 'orders' => [], - ], + new Index( + key: '_key_installationId', + type: IndexType::Key, + attributes: ['installationId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_installationInternalId', + type: IndexType::Key, + attributes: ['installationInternalId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_projectInternalId', + type: IndexType::Key, + attributes: ['projectInternalId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_projectId', + type: IndexType::Key, + attributes: ['projectId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_providerRepositoryId', + type: IndexType::Key, + attributes: ['providerRepositoryId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_resourceId', + type: IndexType::Key, + attributes: ['resourceId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_resourceInternalId', + type: IndexType::Key, + attributes: ['resourceInternalId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_resourceType', + type: IndexType::Key, + attributes: ['resourceType'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_piid_riid_rt', + type: IndexType::Key, + attributes: ['projectInternalId', 'resourceInternalId', 'resourceType'], + ), ], ], - 'vcsComments' => [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('vcsComments'), + '$collection' => '_metadata', + '$id' => 'vcsComments', 'name' => 'vcsComments', 'attributes' => [ - [ - '$id' => ID::custom('installationId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [] - ], - [ - '$id' => ID::custom('installationInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('projectId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [] - ], - [ - '$id' => ID::custom('projectInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('providerRepositoryId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [] - ], - [ - '$id' => ID::custom('providerCommentId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [] - ], - [ - '$id' => ID::custom('providerPullRequestId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [] - ], - [ - '$id' => ID::custom('providerBranch'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [] - ], + new Attribute( + key: 'installationId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'installationInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'projectId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'projectInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'providerRepositoryId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'providerCommentId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'providerPullRequestId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'providerBranch', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_key_installationId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['installationId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_installationInternalId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['installationInternalId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_projectInternalId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['projectInternalId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_projectId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['projectId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_providerRepositoryId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['providerRepositoryId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_providerPullRequestId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['providerPullRequestId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_providerBranch'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['providerBranch'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_piid_prid_rt'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['projectInternalId', 'providerRepositoryId'], - 'lengths' => [], - 'orders' => [], - ], + new Index( + key: '_key_installationId', + type: IndexType::Key, + attributes: ['installationId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_installationInternalId', + type: IndexType::Key, + attributes: ['installationInternalId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_projectInternalId', + type: IndexType::Key, + attributes: ['projectInternalId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_projectId', + type: IndexType::Key, + attributes: ['projectId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_providerRepositoryId', + type: IndexType::Key, + attributes: ['providerRepositoryId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_providerPullRequestId', + type: IndexType::Key, + attributes: ['providerPullRequestId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_providerBranch', + type: IndexType::Key, + attributes: ['providerBranch'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_piid_prid_rt', + type: IndexType::Key, + attributes: ['projectInternalId', 'providerRepositoryId'], + ), ], ], - 'vcsCommentLocks' => [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('vcsCommentLocks'), + '$collection' => '_metadata', + '$id' => 'vcsCommentLocks', 'name' => 'vcsCommentLocks', - 'attributes' => [], - 'indexes' => [] + 'attributes' => [ + ], + 'indexes' => [ + ], + ], + 'teams' => [ + 'attributes' => [ + new Attribute( + key: 'keys', + type: ColumnType::String, + size: 16384, + filters: ['subQueryOrganizationKeys'], + ), + ], + ], + 'users' => [ + 'attributes' => [ + new Attribute( + key: 'keys', + type: ColumnType::String, + size: 16384, + filters: ['subQueryAccountKeys'], + ), + ], ], ]; - -// Organization API keys subquery -$platformCollections['teams']['attributes'][] = [ - '$id' => ID::custom('keys'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['subQueryOrganizationKeys'], -]; - -// Account API keys subquery -$platformCollections['users']['attributes'][] = [ - '$id' => ID::custom('keys'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['subQueryAccountKeys'], -]; - -return $platformCollections; diff --git a/app/config/collections/projects.php b/app/config/collections/projects.php index b41e8f0fd5..19f422452d 100644 --- a/app/config/collections/projects.php +++ b/app/config/collections/projects.php @@ -1,2757 +1,1628 @@ [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('databases'), + '$collection' => '_metadata', + '$id' => 'databases', 'name' => 'Databases', 'attributes' => [ - [ - '$id' => ID::custom('name'), - 'type' => Database::VAR_STRING, - 'size' => 256, - 'required' => true, - 'signed' => true, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('enabled'), - 'type' => Database::VAR_BOOLEAN, - 'signed' => true, - 'size' => 0, - 'format' => '', - 'filters' => [], - 'required' => false, - 'default' => true, - 'array' => false, - ], - [ - '$id' => ID::custom('search'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('originalId'), - 'type' => Database::VAR_STRING, - 'signed' => true, - 'size' => Database::LENGTH_KEY, - 'format' => '', - 'filters' => [], - 'required' => false, - 'default' => null, - 'array' => false, - ], - [ - '$id' => ID::custom('type'), - 'type' => Database::VAR_STRING, - 'size' => 128, - 'required' => false, - 'default' => 'tablesdb', - 'signed' => true, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('database'), - 'type' => Database::VAR_STRING, - 'size' => 128, - 'required' => false, - 'signed' => true, - 'array' => false, - 'filters' => [], - ] + new Attribute( + key: 'name', + type: ColumnType::String, + size: 256, + required: true, + ), + new Attribute( + key: 'enabled', + type: ColumnType::Boolean, + default: true, + ), + new Attribute( + key: 'search', + type: ColumnType::String, + size: 16384, + ), + new Attribute( + key: 'originalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'type', + type: ColumnType::String, + size: 128, + default: 'tablesdb', + ), + new Attribute( + key: 'database', + type: ColumnType::String, + size: 128, + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_fulltext_search'), - 'type' => Database::INDEX_FULLTEXT, - 'attributes' => ['search'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => ID::custom('_key_name'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['name'], - 'lengths' => [256], - 'orders' => [Database::ORDER_ASC], - ], + new Index( + key: '_fulltext_search', + type: IndexType::Fulltext, + attributes: ['search'], + ), + new Index( + key: '_key_name', + type: IndexType::Key, + attributes: ['name'], + lengths: [256], + orders: ['ASC'], + ), ], ], - 'attributes' => [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('attributes'), + '$collection' => '_metadata', + '$id' => 'attributes', 'name' => 'Attributes', 'attributes' => [ - [ - '$id' => ID::custom('databaseInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('databaseId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => false, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('collectionInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('collectionId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('key'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('type'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('status'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('error'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2048, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('size'), - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('required'), - 'type' => Database::VAR_BOOLEAN, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('default'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['casting'], - ], - [ - '$id' => ID::custom('signed'), - 'type' => Database::VAR_BOOLEAN, - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('array'), - 'type' => Database::VAR_BOOLEAN, - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('format'), - 'type' => Database::VAR_STRING, - 'size' => 64, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('formatOptions'), - 'type' => Database::VAR_STRING, - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => new stdClass(), - 'array' => false, - 'filters' => ['json', 'range', 'enum'], - ], - [ - '$id' => ID::custom('filters'), - 'type' => Database::VAR_STRING, - 'size' => 64, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => true, - 'filters' => [], - ], - [ - '$id' => ID::custom('options'), - 'type' => Database::VAR_STRING, - 'size' => 16384, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['json'], - ], + new Attribute( + key: 'databaseInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'databaseId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + signed: false, + ), + new Attribute( + key: 'collectionInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'collectionId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'key', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'type', + type: ColumnType::String, + size: 256, + ), + new Attribute( + key: 'status', + type: ColumnType::String, + size: 16, + ), + new Attribute( + key: 'error', + type: ColumnType::String, + size: 2048, + ), + new Attribute( + key: 'size', + type: ColumnType::Integer, + ), + new Attribute( + key: 'required', + type: ColumnType::Boolean, + ), + new Attribute( + key: 'default', + type: ColumnType::String, + size: 16384, + filters: ['casting'], + ), + new Attribute( + key: 'signed', + type: ColumnType::Boolean, + ), + new Attribute( + key: 'array', + type: ColumnType::Boolean, + ), + new Attribute( + key: 'format', + type: ColumnType::String, + size: 64, + ), + new Attribute( + key: 'formatOptions', + type: ColumnType::String, + size: 16384, + default: (object) array( + ), + filters: ['json', 'range', 'enum'], + ), + new Attribute( + key: 'filters', + type: ColumnType::String, + size: 64, + array: true, + ), + new Attribute( + key: 'options', + type: ColumnType::String, + size: 16384, + signed: false, + filters: ['json'], + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_key_db_collection'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['databaseInternalId', 'collectionInternalId'], - 'lengths' => [Database::LENGTH_KEY, Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC, Database::ORDER_ASC], - ], + new Index( + key: '_key_db_collection', + type: IndexType::Key, + attributes: ['databaseInternalId', 'collectionInternalId'], + lengths: [255, 255], + orders: ['ASC', 'ASC'], + ), ], ], - 'indexes' => [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('indexes'), + '$collection' => '_metadata', + '$id' => 'indexes', 'name' => 'Indexes', 'attributes' => [ - [ - '$id' => ID::custom('databaseInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('databaseId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => false, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('collectionInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('collectionId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('key'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('type'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('status'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('error'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2048, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('attributes'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => true, - 'filters' => [], - ], - [ - '$id' => ID::custom('lengths'), - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => true, - 'filters' => [], - ], - [ - '$id' => ID::custom('orders'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 4, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => true, - 'filters' => [], - ], + new Attribute( + key: 'databaseInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'databaseId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + signed: false, + ), + new Attribute( + key: 'collectionInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'collectionId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'key', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'type', + type: ColumnType::String, + size: 16, + ), + new Attribute( + key: 'status', + type: ColumnType::String, + size: 16, + ), + new Attribute( + key: 'error', + type: ColumnType::String, + size: 2048, + ), + new Attribute( + key: 'attributes', + type: ColumnType::String, + size: Database::LENGTH_KEY, + array: true, + ), + new Attribute( + key: 'lengths', + type: ColumnType::Integer, + array: true, + ), + new Attribute( + key: 'orders', + type: ColumnType::String, + size: 4, + array: true, + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_key_db_collection'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['databaseInternalId', 'collectionInternalId'], - 'lengths' => [Database::LENGTH_KEY, Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC, Database::ORDER_ASC], - ], + new Index( + key: '_key_db_collection', + type: IndexType::Key, + attributes: ['databaseInternalId', 'collectionInternalId'], + lengths: [255, 255], + orders: ['ASC', 'ASC'], + ), ], ], - 'functions' => [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('functions'), + '$collection' => '_metadata', + '$id' => 'functions', 'name' => 'Functions', 'attributes' => [ - [ - '$id' => ID::custom('execute'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => true, - 'filters' => [], - ], - [ - '$id' => ID::custom('name'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2048, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('enabled'), - 'type' => Database::VAR_BOOLEAN, - 'signed' => true, - 'size' => 0, - 'format' => '', - 'filters' => [], - 'required' => true, - 'array' => false, - ], - [ - '$id' => ID::custom('live'), - 'type' => Database::VAR_BOOLEAN, - 'signed' => true, - 'size' => 0, - 'format' => '', - 'filters' => [], - 'required' => true, - 'array' => false, - ], - [ - '$id' => ID::custom('installationId'), - 'type' => Database::VAR_STRING, - 'signed' => true, - 'size' => Database::LENGTH_KEY, - 'format' => '', - 'filters' => [], - 'required' => false, - 'array' => false, - ], - [ - '$id' => ID::custom('installationInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('providerRepositoryId'), - 'type' => Database::VAR_STRING, - 'signed' => true, - 'size' => Database::LENGTH_KEY, - 'format' => '', - 'filters' => [], - 'required' => false, - 'array' => false, - ], - [ - '$id' => ID::custom('repositoryId'), - 'type' => Database::VAR_STRING, - 'signed' => true, - 'size' => Database::LENGTH_KEY, - 'format' => '', - 'filters' => [], - 'required' => false, - 'array' => false, - ], - [ - '$id' => ID::custom('repositoryInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('providerBranch'), - 'type' => Database::VAR_STRING, - 'signed' => true, - 'size' => Database::LENGTH_KEY, - 'format' => '', - 'filters' => [], - 'required' => false, - 'array' => false, - ], - [ - '$id' => ID::custom('providerRootDirectory'), - 'type' => Database::VAR_STRING, - 'signed' => true, - 'size' => Database::LENGTH_KEY, - 'format' => '', - 'filters' => [], - 'required' => false, - 'array' => false, - ], - [ - '$id' => ID::custom('providerSilentMode'), - 'type' => Database::VAR_BOOLEAN, - 'signed' => true, - 'size' => 0, - 'format' => '', - 'filters' => [], - 'required' => false, - 'default' => false, - 'array' => false, - ], - [ - '$id' => ID::custom('logging'), - 'type' => Database::VAR_BOOLEAN, - 'signed' => true, - 'size' => 0, - 'format' => '', - 'filters' => [], - 'required' => true, - 'array' => false, - ], - [ - '$id' => ID::custom('runtime'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2048, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('deploymentRetention'), - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => 0, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('deploymentInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('deploymentId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('deploymentCreatedAt'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('latestDeploymentId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('latestDeploymentInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('latestDeploymentCreatedAt'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('latestDeploymentStatus'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16, - 'signed' => true, - 'required' => false, - 'default' => '', - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('vars'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['subQueryVariables'], - ], - [ - '$id' => ID::custom('varsProject'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['subQueryProjectVariables'], - ], - [ - '$id' => ID::custom('events'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 256, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => true, - 'filters' => [], - ], - [ - '$id' => ID::custom('scheduleInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('scheduleId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('schedule'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('timeout'), - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('search'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('version'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 8, - 'signed' => true, - 'required' => false, - 'default' => 'v5', - 'array' => false, - 'filters' => [], - ], - [ - 'array' => false, - '$id' => ID::custom('entrypoint'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'filters' => [], - ], - [ - 'array' => false, - '$id' => ID::custom('commands'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'filters' => [], - ], - [ - // At the moment, always empty (no runtime supports it yet) - 'array' => false, - '$id' => ID::custom('startCommand'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 20000, - 'signed' => true, - 'required' => false, - 'default' => null, - 'filters' => [], - ], - [ - 'array' => false, - '$id' => ID::custom('specification'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => false, - 'required' => false, - 'default' => APP_COMPUTE_SPECIFICATION_DEFAULT, - 'filters' => [], - ], - [ - 'array' => false, - '$id' => ID::custom('buildSpecification'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => false, - 'required' => false, - 'default' => APP_COMPUTE_SPECIFICATION_DEFAULT, - 'filters' => [], - ], - [ - 'array' => false, - '$id' => ID::custom('runtimeSpecification'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => false, - 'required' => false, - 'default' => APP_COMPUTE_SPECIFICATION_DEFAULT, - 'filters' => [], - ], - [ - '$id' => ID::custom('scopes'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => [], - 'array' => true, - 'filters' => [], - ], + new Attribute( + key: 'execute', + type: ColumnType::String, + size: 128, + array: true, + ), + new Attribute( + key: 'name', + type: ColumnType::String, + size: 2048, + ), + new Attribute( + key: 'enabled', + type: ColumnType::Boolean, + required: true, + ), + new Attribute( + key: 'live', + type: ColumnType::Boolean, + required: true, + ), + new Attribute( + key: 'installationId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'installationInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'providerRepositoryId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'repositoryId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'repositoryInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'providerBranch', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'providerRootDirectory', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'providerSilentMode', + type: ColumnType::Boolean, + default: false, + ), + new Attribute( + key: 'logging', + type: ColumnType::Boolean, + required: true, + ), + new Attribute( + key: 'runtime', + type: ColumnType::String, + size: 2048, + ), + new Attribute( + key: 'deploymentRetention', + type: ColumnType::Integer, + default: 0, + ), + new Attribute( + key: 'deploymentInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'deploymentId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'deploymentCreatedAt', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), + new Attribute( + key: 'latestDeploymentId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'latestDeploymentInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'latestDeploymentCreatedAt', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), + new Attribute( + key: 'latestDeploymentStatus', + type: ColumnType::String, + size: 16, + default: '', + ), + new Attribute( + key: 'vars', + type: ColumnType::String, + size: 16384, + filters: ['subQueryVariables'], + ), + new Attribute( + key: 'varsProject', + type: ColumnType::String, + size: 16384, + filters: ['subQueryProjectVariables'], + ), + new Attribute( + key: 'events', + type: ColumnType::String, + size: 256, + array: true, + ), + new Attribute( + key: 'scheduleInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'scheduleId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'schedule', + type: ColumnType::String, + size: 128, + ), + new Attribute( + key: 'timeout', + type: ColumnType::Integer, + ), + new Attribute( + key: 'search', + type: ColumnType::String, + size: 16384, + ), + new Attribute( + key: 'version', + type: ColumnType::String, + size: 8, + default: 'v5', + ), + new Attribute( + key: 'entrypoint', + type: ColumnType::String, + size: 16384, + ), + new Attribute( + key: 'commands', + type: ColumnType::String, + size: 16384, + ), + new Attribute( + key: 'startCommand', + type: ColumnType::String, + size: 20000, + ), + new Attribute( + key: 'specification', + type: ColumnType::String, + size: 128, + default: 's-1vcpu-512mb', + signed: false, + ), + new Attribute( + key: 'buildSpecification', + type: ColumnType::String, + size: 128, + default: 's-1vcpu-512mb', + signed: false, + ), + new Attribute( + key: 'runtimeSpecification', + type: ColumnType::String, + size: 128, + default: 's-1vcpu-512mb', + signed: false, + ), + new Attribute( + key: 'scopes', + type: ColumnType::String, + size: Database::LENGTH_KEY, + default: [], + array: true, + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_key_search'), - 'type' => Database::INDEX_FULLTEXT, - 'attributes' => ['search'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => ID::custom('_key_name'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['name'], - 'lengths' => [256], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_enabled'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['enabled'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_installationId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['installationId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_installationInternalId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['installationInternalId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_providerRepositoryId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['providerRepositoryId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_repositoryId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['repositoryId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_repositoryInternalId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['repositoryInternalId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_runtime'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['runtime'], - 'lengths' => [64], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_deploymentId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['deploymentId'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ] + new Index( + key: '_key_search', + type: IndexType::Fulltext, + attributes: ['search'], + ), + new Index( + key: '_key_name', + type: IndexType::Key, + attributes: ['name'], + lengths: [256], + orders: ['ASC'], + ), + new Index( + key: '_key_enabled', + type: IndexType::Key, + attributes: ['enabled'], + orders: ['ASC'], + ), + new Index( + key: '_key_installationId', + type: IndexType::Key, + attributes: ['installationId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_installationInternalId', + type: IndexType::Key, + attributes: ['installationInternalId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_providerRepositoryId', + type: IndexType::Key, + attributes: ['providerRepositoryId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_repositoryId', + type: IndexType::Key, + attributes: ['repositoryId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_repositoryInternalId', + type: IndexType::Key, + attributes: ['repositoryInternalId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_runtime', + type: IndexType::Key, + attributes: ['runtime'], + lengths: [64], + orders: ['ASC'], + ), + new Index( + key: '_key_deploymentId', + type: IndexType::Key, + attributes: ['deploymentId'], + orders: ['ASC'], + ), ], ], - 'sites' => [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('sites'), + '$collection' => '_metadata', + '$id' => 'sites', 'name' => 'Sites', 'attributes' => [ - [ - '$id' => ID::custom('name'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2048, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('enabled'), - 'type' => Database::VAR_BOOLEAN, - 'signed' => true, - 'size' => 0, - 'format' => '', - 'filters' => [], - 'required' => true, - 'array' => false, - ], - [ - '$id' => ID::custom('live'), - 'type' => Database::VAR_BOOLEAN, - 'signed' => true, - 'size' => 0, - 'format' => '', - 'filters' => [], - 'required' => true, - 'array' => false, - ], - [ - '$id' => ID::custom('installationId'), - 'type' => Database::VAR_STRING, - 'signed' => true, - 'size' => Database::LENGTH_KEY, - 'format' => '', - 'filters' => [], - 'required' => false, - 'array' => false, - ], - [ - '$id' => ID::custom('installationInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('providerRepositoryId'), - 'type' => Database::VAR_STRING, - 'signed' => true, - 'size' => Database::LENGTH_KEY, - 'format' => '', - 'filters' => [], - 'required' => false, - 'array' => false, - ], - [ - '$id' => ID::custom('repositoryId'), - 'type' => Database::VAR_STRING, - 'signed' => true, - 'size' => Database::LENGTH_KEY, - 'format' => '', - 'filters' => [], - 'required' => false, - 'array' => false, - ], - [ - '$id' => ID::custom('repositoryInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('providerBranch'), - 'type' => Database::VAR_STRING, - 'signed' => true, - 'size' => Database::LENGTH_KEY, - 'format' => '', - 'filters' => [], - 'required' => false, - 'array' => false, - ], - [ - '$id' => ID::custom('providerRootDirectory'), - 'type' => Database::VAR_STRING, - 'signed' => true, - 'size' => Database::LENGTH_KEY, - 'format' => '', - 'filters' => [], - 'required' => false, - 'array' => false, - ], - [ - '$id' => ID::custom('providerSilentMode'), - 'type' => Database::VAR_BOOLEAN, - 'signed' => true, - 'size' => 0, - 'format' => '', - 'filters' => [], - 'required' => false, - 'default' => false, - 'array' => false, - ], - [ - '$id' => ID::custom('logging'), - 'type' => Database::VAR_BOOLEAN, - 'signed' => true, - 'size' => 0, - 'format' => '', - 'filters' => [], - 'required' => true, - 'array' => false, - ], - [ - '$id' => ID::custom('framework'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2048, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - 'array' => false, - '$id' => ID::custom('outputDirectory'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'filters' => [], - ], - [ - 'array' => false, - '$id' => ID::custom('buildCommand'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'filters' => [], - ], - [ - 'array' => false, - '$id' => ID::custom('installCommand'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'filters' => [], - ], - [ - 'array' => false, - '$id' => ID::custom('startCommand'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 20000, - 'signed' => true, - 'required' => false, - 'default' => null, - 'filters' => [], - ], - [ - '$id' => ID::custom('fallbackFile'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('deploymentRetention'), - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => 0, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('deploymentInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('deploymentId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('deploymentCreatedAt'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('deploymentScreenshotLight'), // File ID from 'screenshots' Console bucket - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 32, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('deploymentScreenshotDark'), // File ID from 'screenshots' Console bucket - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 32, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('latestDeploymentId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('latestDeploymentInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('latestDeploymentCreatedAt'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('latestDeploymentStatus'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16, - 'signed' => true, - 'required' => false, - 'default' => '', - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('vars'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['subQueryVariables'], - ], - [ - '$id' => ID::custom('varsProject'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['subQueryProjectVariables'], - ], - [ - '$id' => ID::custom('timeout'), - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('search'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - 'array' => false, - '$id' => ID::custom('specification'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => false, - 'required' => false, - 'default' => APP_COMPUTE_SPECIFICATION_DEFAULT, - 'filters' => [], - ], - [ - 'array' => false, - '$id' => ID::custom('buildSpecification'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => false, - 'required' => false, - 'default' => APP_COMPUTE_SPECIFICATION_DEFAULT, - 'filters' => [], - ], - [ - 'array' => false, - '$id' => ID::custom('runtimeSpecification'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => false, - 'required' => false, - 'default' => APP_COMPUTE_SPECIFICATION_DEFAULT, - 'filters' => [], - ], - [ - '$id' => ID::custom('buildRuntime'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2048, - 'signed' => true, - 'required' => true, - 'default' => '', - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('adapter'), // ssr or static; named this way as it's a term in SSR frameworks - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16, - 'signed' => true, - 'required' => false, - 'default' => '', - 'array' => false, - 'filters' => [], - ], + new Attribute( + key: 'name', + type: ColumnType::String, + size: 2048, + ), + new Attribute( + key: 'enabled', + type: ColumnType::Boolean, + required: true, + ), + new Attribute( + key: 'live', + type: ColumnType::Boolean, + required: true, + ), + new Attribute( + key: 'installationId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'installationInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'providerRepositoryId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'repositoryId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'repositoryInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'providerBranch', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'providerRootDirectory', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'providerSilentMode', + type: ColumnType::Boolean, + default: false, + ), + new Attribute( + key: 'logging', + type: ColumnType::Boolean, + required: true, + ), + new Attribute( + key: 'framework', + type: ColumnType::String, + size: 2048, + ), + new Attribute( + key: 'outputDirectory', + type: ColumnType::String, + size: 16384, + ), + new Attribute( + key: 'buildCommand', + type: ColumnType::String, + size: 16384, + ), + new Attribute( + key: 'installCommand', + type: ColumnType::String, + size: 16384, + ), + new Attribute( + key: 'startCommand', + type: ColumnType::String, + size: 20000, + ), + new Attribute( + key: 'fallbackFile', + type: ColumnType::String, + size: 16384, + ), + new Attribute( + key: 'deploymentRetention', + type: ColumnType::Integer, + default: 0, + ), + new Attribute( + key: 'deploymentInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'deploymentId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'deploymentCreatedAt', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), + new Attribute( + key: 'deploymentScreenshotLight', + type: ColumnType::String, + size: 32, + signed: false, + ), + new Attribute( + key: 'deploymentScreenshotDark', + type: ColumnType::String, + size: 32, + signed: false, + ), + new Attribute( + key: 'latestDeploymentId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'latestDeploymentInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'latestDeploymentCreatedAt', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), + new Attribute( + key: 'latestDeploymentStatus', + type: ColumnType::String, + size: 16, + default: '', + ), + new Attribute( + key: 'vars', + type: ColumnType::String, + size: 16384, + filters: ['subQueryVariables'], + ), + new Attribute( + key: 'varsProject', + type: ColumnType::String, + size: 16384, + filters: ['subQueryProjectVariables'], + ), + new Attribute( + key: 'timeout', + type: ColumnType::Integer, + ), + new Attribute( + key: 'search', + type: ColumnType::String, + size: 16384, + ), + new Attribute( + key: 'specification', + type: ColumnType::String, + size: 128, + default: 's-1vcpu-512mb', + signed: false, + ), + new Attribute( + key: 'buildSpecification', + type: ColumnType::String, + size: 128, + default: 's-1vcpu-512mb', + signed: false, + ), + new Attribute( + key: 'runtimeSpecification', + type: ColumnType::String, + size: 128, + default: 's-1vcpu-512mb', + signed: false, + ), + new Attribute( + key: 'buildRuntime', + type: ColumnType::String, + size: 2048, + required: true, + default: '', + ), + new Attribute( + key: 'adapter', + type: ColumnType::String, + size: 16, + default: '', + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_key_search'), - 'type' => Database::INDEX_FULLTEXT, - 'attributes' => ['search'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => ID::custom('_key_name'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['name'], - 'lengths' => [256], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_enabled'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['enabled'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_installationId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['installationId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_installationInternalId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['installationInternalId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_providerRepositoryId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['providerRepositoryId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_repositoryId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['repositoryId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_repositoryInternalId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['repositoryInternalId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_framework'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['framework'], - 'lengths' => [64], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_deploymentId'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['deploymentId'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ] + new Index( + key: '_key_search', + type: IndexType::Fulltext, + attributes: ['search'], + ), + new Index( + key: '_key_name', + type: IndexType::Key, + attributes: ['name'], + lengths: [256], + orders: ['ASC'], + ), + new Index( + key: '_key_enabled', + type: IndexType::Key, + attributes: ['enabled'], + orders: ['ASC'], + ), + new Index( + key: '_key_installationId', + type: IndexType::Key, + attributes: ['installationId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_installationInternalId', + type: IndexType::Key, + attributes: ['installationInternalId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_providerRepositoryId', + type: IndexType::Key, + attributes: ['providerRepositoryId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_repositoryId', + type: IndexType::Key, + attributes: ['repositoryId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_repositoryInternalId', + type: IndexType::Key, + attributes: ['repositoryInternalId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_framework', + type: IndexType::Key, + attributes: ['framework'], + lengths: [64], + orders: ['ASC'], + ), + new Index( + key: '_key_deploymentId', + type: IndexType::Key, + attributes: ['deploymentId'], + orders: ['ASC'], + ), ], ], - 'deployments' => [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('deployments'), + '$collection' => '_metadata', + '$id' => 'deployments', 'name' => 'Deployments', 'attributes' => [ - [ - '$id' => ID::custom('resourceInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('resourceId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('resourceType'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - 'array' => false, - '$id' => ID::custom('entrypoint'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2048, - 'signed' => true, - 'required' => false, - 'default' => null, - 'filters' => [], - ], - [ - 'array' => false, - '$id' => ID::custom('buildCommands'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'filters' => [], - ], - [ - 'array' => false, - '$id' => ID::custom('startCommand'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 20000, - 'signed' => true, - 'required' => false, - 'default' => null, - 'filters' => [], - ], - [ - 'array' => false, - '$id' => ID::custom('buildOutput'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'filters' => [], - ], - [ - '$id' => ID::custom('sourcePath'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('type'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2048, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('installationId'), - 'type' => Database::VAR_STRING, - 'signed' => true, - 'size' => Database::LENGTH_KEY, - 'format' => '', - 'filters' => [], - 'required' => false, - 'array' => false, - ], - [ - '$id' => ID::custom('installationInternalId'), - 'type' => Database::VAR_STRING, - 'signed' => true, - 'size' => Database::LENGTH_KEY, - 'format' => '', - 'filters' => [], - 'required' => false, - 'array' => false, - ], - [ - '$id' => ID::custom('providerRepositoryId'), - 'type' => Database::VAR_STRING, - 'signed' => true, - 'size' => Database::LENGTH_KEY, - 'format' => '', - 'filters' => [], - 'required' => false, - 'array' => false, - ], - [ - '$id' => ID::custom('repositoryId'), - 'type' => Database::VAR_STRING, - 'signed' => true, - 'size' => Database::LENGTH_KEY, - 'format' => '', - 'filters' => [], - 'required' => false, - 'array' => false, - ], - [ - '$id' => ID::custom('repositoryInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('providerRepositoryName'), - 'type' => Database::VAR_STRING, - 'signed' => true, - 'size' => Database::LENGTH_KEY, - 'format' => '', - 'filters' => [], - 'required' => false, - 'array' => false, - ], - [ - '$id' => ID::custom('providerRepositoryOwner'), - 'type' => Database::VAR_STRING, - 'signed' => true, - 'size' => Database::LENGTH_KEY, - 'format' => '', - 'filters' => [], - 'required' => false, - 'array' => false, - ], - [ - '$id' => ID::custom('providerRepositoryUrl'), - 'type' => Database::VAR_STRING, - 'signed' => true, - 'size' => Database::LENGTH_KEY, - 'format' => '', - 'filters' => [], - 'required' => false, - 'array' => false, - ], - [ - '$id' => ID::custom('providerCommitHash'), - 'type' => Database::VAR_STRING, - 'signed' => true, - 'size' => Database::LENGTH_KEY, - 'format' => '', - 'filters' => [], - 'required' => false, - 'array' => false, - ], - [ - '$id' => ID::custom('providerCommitAuthorUrl'), - 'type' => Database::VAR_STRING, - 'signed' => true, - 'size' => Database::LENGTH_KEY, - 'format' => '', - 'filters' => [], - 'required' => false, - 'array' => false, - ], - [ - '$id' => ID::custom('providerCommitAuthor'), - 'type' => Database::VAR_STRING, - 'signed' => true, - 'size' => Database::LENGTH_KEY, - 'format' => '', - 'filters' => [], - 'required' => false, - 'array' => false, - ], - [ - '$id' => ID::custom('providerCommitMessage'), - 'type' => Database::VAR_STRING, - 'signed' => true, - 'size' => Database::LENGTH_KEY, - 'format' => '', - 'filters' => [], - 'required' => false, - 'array' => false, - ], - [ - '$id' => ID::custom('providerCommitUrl'), - 'type' => Database::VAR_STRING, - 'signed' => true, - 'size' => Database::LENGTH_KEY, - 'format' => '', - 'filters' => [], - 'required' => false, - 'array' => false, - ], - [ - '$id' => ID::custom('providerBranch'), - 'type' => Database::VAR_STRING, - 'signed' => true, - 'size' => Database::LENGTH_KEY, - 'format' => '', - 'filters' => [], - 'required' => false, - 'array' => false, - ], - [ - '$id' => ID::custom('providerBranchUrl'), - 'type' => Database::VAR_STRING, - 'signed' => true, - 'size' => Database::LENGTH_KEY, - 'format' => '', - 'filters' => [], - 'required' => false, - 'array' => false, - ], - [ - '$id' => ID::custom('providerRootDirectory'), - 'type' => Database::VAR_STRING, - 'signed' => true, - 'size' => Database::LENGTH_KEY, - 'format' => '', - 'filters' => [], - 'required' => false, - 'array' => false, - ], - [ - '$id' => ID::custom('providerCommentId'), - 'type' => Database::VAR_STRING, - 'signed' => true, - 'size' => 2048, - 'format' => '', - 'filters' => [], - 'required' => false, - 'array' => false, - ], - [ - '$id' => ID::custom('sourceSize'), - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 8, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('sourceMetadata'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, // https://tools.ietf.org/html/rfc4288#section-4.2 - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['json'], - ], - [ - '$id' => ID::custom('sourceChunksTotal'), - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('sourceChunksUploaded'), - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('activate'), - 'type' => Database::VAR_BOOLEAN, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => false, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('screenshotLight'), // File ID from 'screenshots' Console bucket - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 32, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('screenshotDark'), // File ID from 'screenshots' Console bucket - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 32, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('buildStartedAt'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('buildEndedAt'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('buildDuration'), - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('buildSize'), - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 8, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('totalSize'), - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 8, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('status'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16, - 'signed' => true, - 'required' => false, - 'default' => 'waiting', - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('buildPath'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => '', - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('buildLogs'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 1000000, - 'signed' => true, - 'required' => false, - 'default' => '', - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('adapter'), // ssr or static; named this way as it's a term in SSR frameworks - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16, - 'signed' => true, - 'required' => false, - 'default' => '', - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('fallbackFile'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ] + new Attribute( + key: 'resourceInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'resourceId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'resourceType', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'entrypoint', + type: ColumnType::String, + size: 2048, + ), + new Attribute( + key: 'buildCommands', + type: ColumnType::String, + size: 16384, + ), + new Attribute( + key: 'startCommand', + type: ColumnType::String, + size: 20000, + ), + new Attribute( + key: 'buildOutput', + type: ColumnType::String, + size: 16384, + ), + new Attribute( + key: 'sourcePath', + type: ColumnType::String, + size: 16384, + ), + new Attribute( + key: 'type', + type: ColumnType::String, + size: 2048, + required: true, + ), + new Attribute( + key: 'installationId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'installationInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'providerRepositoryId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'repositoryId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'repositoryInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'providerRepositoryName', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'providerRepositoryOwner', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'providerRepositoryUrl', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'providerCommitHash', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'providerCommitAuthorUrl', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'providerCommitAuthor', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'providerCommitMessage', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'providerCommitUrl', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'providerBranch', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'providerBranchUrl', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'providerRootDirectory', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'providerCommentId', + type: ColumnType::String, + size: 2048, + ), + new Attribute( + key: 'sourceSize', + type: ColumnType::Integer, + size: 8, + signed: false, + ), + new Attribute( + key: 'sourceMetadata', + type: ColumnType::String, + size: 16384, + filters: ['json'], + ), + new Attribute( + key: 'sourceChunksTotal', + type: ColumnType::Integer, + signed: false, + ), + new Attribute( + key: 'sourceChunksUploaded', + type: ColumnType::Integer, + signed: false, + ), + new Attribute( + key: 'activate', + type: ColumnType::Boolean, + default: false, + ), + new Attribute( + key: 'screenshotLight', + type: ColumnType::String, + size: 32, + signed: false, + ), + new Attribute( + key: 'screenshotDark', + type: ColumnType::String, + size: 32, + signed: false, + ), + new Attribute( + key: 'buildStartedAt', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), + new Attribute( + key: 'buildEndedAt', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), + new Attribute( + key: 'buildDuration', + type: ColumnType::Integer, + signed: false, + ), + new Attribute( + key: 'buildSize', + type: ColumnType::Integer, + size: 8, + signed: false, + ), + new Attribute( + key: 'totalSize', + type: ColumnType::Integer, + size: 8, + signed: false, + ), + new Attribute( + key: 'status', + type: ColumnType::String, + size: 16, + default: 'waiting', + ), + new Attribute( + key: 'buildPath', + type: ColumnType::String, + size: 16384, + default: '', + ), + new Attribute( + key: 'buildLogs', + type: ColumnType::String, + size: 1000000, + default: '', + ), + new Attribute( + key: 'adapter', + type: ColumnType::String, + size: 16, + default: '', + ), + new Attribute( + key: 'fallbackFile', + type: ColumnType::String, + size: 16384, + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_key_resource'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['resourceId'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_resource_type'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['resourceType'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_sourceSize'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['sourceSize'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_buildSize'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['buildSize'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_totalSize'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['totalSize'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_buildDuration'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['buildDuration'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_activate'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['activate'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_type'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['type'], - 'lengths' => [32], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_status'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['status'], - 'lengths' => [16], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_resourceId_resourceType'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['resourceId', 'resourceType'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => ID::custom('_key_resource_internal_id'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['resourceInternalId'], - 'lengths' => [], - 'orders' => [], - ], + new Index( + key: '_key_resource', + type: IndexType::Key, + attributes: ['resourceId'], + orders: ['ASC'], + ), + new Index( + key: '_key_resource_type', + type: IndexType::Key, + attributes: ['resourceType'], + orders: ['ASC'], + ), + new Index( + key: '_key_sourceSize', + type: IndexType::Key, + attributes: ['sourceSize'], + orders: ['ASC'], + ), + new Index( + key: '_key_buildSize', + type: IndexType::Key, + attributes: ['buildSize'], + orders: ['ASC'], + ), + new Index( + key: '_key_totalSize', + type: IndexType::Key, + attributes: ['totalSize'], + orders: ['ASC'], + ), + new Index( + key: '_key_buildDuration', + type: IndexType::Key, + attributes: ['buildDuration'], + orders: ['ASC'], + ), + new Index( + key: '_key_activate', + type: IndexType::Key, + attributes: ['activate'], + orders: ['ASC'], + ), + new Index( + key: '_key_type', + type: IndexType::Key, + attributes: ['type'], + lengths: [32], + orders: ['ASC'], + ), + new Index( + key: '_key_status', + type: IndexType::Key, + attributes: ['status'], + lengths: [16], + orders: ['ASC'], + ), + new Index( + key: '_key_resourceId_resourceType', + type: IndexType::Key, + attributes: ['resourceId', 'resourceType'], + ), + new Index( + key: '_key_resource_internal_id', + type: IndexType::Key, + attributes: ['resourceInternalId'], + ), ], ], - 'executions' => [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('executions'), + '$collection' => '_metadata', + '$id' => 'executions', 'name' => 'Executions', 'attributes' => [ - [ - '$id' => ID::custom('resourceInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('resourceId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('resourceType'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('deploymentInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('deploymentId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - 'array' => false, - '$id' => ID::custom('trigger'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => true, - 'required' => false, - 'default' => null, - 'filters' => [], - ], - [ - '$id' => ID::custom('status'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('duration'), - 'type' => Database::VAR_FLOAT, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('errors'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => APP_FUNCTION_ERROR_LENGTH_LIMIT, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('logs'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => APP_FUNCTION_LOG_LENGTH_LIMIT, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - 'array' => false, - '$id' => ID::custom('requestMethod'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => true, - 'required' => false, - 'default' => null, - 'filters' => [], - ], - [ - 'array' => false, - '$id' => ID::custom('requestPath'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2048, - 'signed' => true, - 'required' => false, - 'default' => null, - 'filters' => [], - ], - [ - '$id' => ID::custom('requestHeaders'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['json'], - ], - [ - '$id' => ID::custom('responseStatusCode'), - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('responseHeaders'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['json'], - ], - [ - '$id' => ID::custom('scheduledAt'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('scheduleInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('scheduleId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], + new Attribute( + key: 'resourceInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'resourceId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'resourceType', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'deploymentInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'deploymentId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'trigger', + type: ColumnType::String, + size: 128, + ), + new Attribute( + key: 'status', + type: ColumnType::String, + size: 128, + ), + new Attribute( + key: 'duration', + type: ColumnType::Float, + ), + new Attribute( + key: 'errors', + type: ColumnType::String, + size: 1000000, + ), + new Attribute( + key: 'logs', + type: ColumnType::String, + size: 1000000, + ), + new Attribute( + key: 'requestMethod', + type: ColumnType::String, + size: 128, + ), + new Attribute( + key: 'requestPath', + type: ColumnType::String, + size: 2048, + ), + new Attribute( + key: 'requestHeaders', + type: ColumnType::String, + size: 16384, + filters: ['json'], + ), + new Attribute( + key: 'responseStatusCode', + type: ColumnType::Integer, + ), + new Attribute( + key: 'responseHeaders', + type: ColumnType::String, + size: 16384, + filters: ['json'], + ), + new Attribute( + key: 'scheduledAt', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), + new Attribute( + key: 'scheduleInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'scheduleId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_key_resource'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['resourceInternalId', 'resourceType', 'resourceId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_trigger'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['trigger'], - 'lengths' => [32], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_status'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['status'], - 'lengths' => [32], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_requestMethod'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['requestMethod'], - 'lengths' => [128], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_requestPath'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['requestPath'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_deployment'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['deploymentId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_responseStatusCode'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['responseStatusCode'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_duration'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['duration'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_resourceType'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['resourceType'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], + new Index( + key: '_key_resource', + type: IndexType::Key, + attributes: ['resourceInternalId', 'resourceType', 'resourceId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_trigger', + type: IndexType::Key, + attributes: ['trigger'], + lengths: [32], + orders: ['ASC'], + ), + new Index( + key: '_key_status', + type: IndexType::Key, + attributes: ['status'], + lengths: [32], + orders: ['ASC'], + ), + new Index( + key: '_key_requestMethod', + type: IndexType::Key, + attributes: ['requestMethod'], + lengths: [128], + orders: ['ASC'], + ), + new Index( + key: '_key_requestPath', + type: IndexType::Key, + attributes: ['requestPath'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_deployment', + type: IndexType::Key, + attributes: ['deploymentId'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_responseStatusCode', + type: IndexType::Key, + attributes: ['responseStatusCode'], + orders: ['ASC'], + ), + new Index( + key: '_key_duration', + type: IndexType::Key, + attributes: ['duration'], + orders: ['ASC'], + ), + new Index( + key: '_key_resourceType', + type: IndexType::Key, + attributes: ['resourceType'], + orders: ['ASC'], + ), ], ], - 'variables' => [ - '$collection' => Database::METADATA, + '$collection' => '_metadata', '$id' => 'variables', 'name' => 'variables', 'attributes' => [ - [ - '$id' => ID::custom('resourceType'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 100, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('resourceInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('resourceId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'key', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => 'value', - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 8192, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => ['encrypt'] - ], - [ - '$id' => ID::custom('secret'), - 'type' => Database::VAR_BOOLEAN, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => false, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('search'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], + new Attribute( + key: 'resourceType', + type: ColumnType::String, + size: 100, + required: true, + ), + new Attribute( + key: 'resourceInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'resourceId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'key', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'value', + type: ColumnType::String, + size: 8192, + required: true, + filters: ['encrypt'], + ), + new Attribute( + key: 'secret', + type: ColumnType::Boolean, + default: false, + ), + new Attribute( + key: 'search', + type: ColumnType::String, + size: 16384, + ), ], 'indexes' => [ - [ - '$id' => '_key_resourceInternalId', - 'type' => Database::INDEX_KEY, - 'attributes' => ['resourceInternalId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [], - ], - [ - '$id' => '_key_resourceType', - 'type' => Database::INDEX_KEY, - 'attributes' => ['resourceType'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => '_key_resourceId_resourceType', - 'type' => Database::INDEX_KEY, - 'attributes' => ['resourceId', 'resourceType'], - 'lengths' => [Database::LENGTH_KEY, 100], - 'orders' => [Database::ORDER_ASC, Database::ORDER_ASC], - ], - [ - '$id' => '_key_uniqueKey', - 'type' => Database::INDEX_UNIQUE, - 'attributes' => ['resourceId', 'key', 'resourceType'], - 'lengths' => [Database::LENGTH_KEY, Database::LENGTH_KEY, 100], - 'orders' => [Database::ORDER_ASC, Database::ORDER_ASC, Database::ORDER_ASC], - ], - [ - '$id' => '_key_key', - 'type' => Database::INDEX_KEY, - 'attributes' => ['key'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_fulltext_search'), - 'type' => Database::INDEX_FULLTEXT, - 'attributes' => ['search'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => ID::custom('_key_resource_internal_id_resource_type'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['resourceInternalId', 'resourceType'], - 'lengths' => [], - 'orders' => [], - ], + new Index( + key: '_key_resourceInternalId', + type: IndexType::Key, + attributes: ['resourceInternalId'], + lengths: [255], + ), + new Index( + key: '_key_resourceType', + type: IndexType::Key, + attributes: ['resourceType'], + orders: ['ASC'], + ), + new Index( + key: '_key_resourceId_resourceType', + type: IndexType::Key, + attributes: ['resourceId', 'resourceType'], + lengths: [255, 100], + orders: ['ASC', 'ASC'], + ), + new Index( + key: '_key_uniqueKey', + type: IndexType::Unique, + attributes: ['resourceId', 'key', 'resourceType'], + lengths: [255, 255, 100], + orders: ['ASC', 'ASC', 'ASC'], + ), + new Index( + key: '_key_key', + type: IndexType::Key, + attributes: ['key'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_fulltext_search', + type: IndexType::Fulltext, + attributes: ['search'], + ), + new Index( + key: '_key_resource_internal_id_resource_type', + type: IndexType::Key, + attributes: ['resourceInternalId', 'resourceType'], + ), ], ], - 'migrations' => [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('migrations'), + '$collection' => '_metadata', + '$id' => 'migrations', 'name' => 'Migrations', 'attributes' => [ - [ - '$id' => ID::custom('status'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('stage'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('source'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 8192, // reduce size - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('destination'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, // make true after patch script - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('credentials'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 65536, - 'signed' => true, - 'required' => false, - 'default' => [], - 'array' => false, - 'filters' => ['json', 'encrypt'], - ], - [ - '$id' => ID::custom('options'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 65536, - 'signed' => true, - 'required' => false, - 'default' => [], - 'array' => false, - 'filters' => ['json'], - ], - [ - '$id' => ID::custom('resources'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => [], - 'array' => true, - 'filters' => [], - ], - [ - '$id' => ID::custom('statusCounters'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 3000, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => ['json'], - ], - [ - '$id' => ID::custom('resourceData'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 131070, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => ['json'], - ], - [ - '$id' => ID::custom('errors'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 1_000_000, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => true, - 'filters' => [], - ], - [ - '$id' => ID::custom('search'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('resourceId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('resourceType'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], + new Attribute( + key: 'status', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'stage', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'source', + type: ColumnType::String, + size: 8192, + required: true, + ), + new Attribute( + key: 'destination', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'credentials', + type: ColumnType::String, + size: 65536, + default: [], + filters: ['json', 'encrypt'], + ), + new Attribute( + key: 'options', + type: ColumnType::String, + size: 65536, + default: [], + filters: ['json'], + ), + new Attribute( + key: 'resources', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + default: [], + array: true, + ), + new Attribute( + key: 'statusCounters', + type: ColumnType::String, + size: 3000, + required: true, + filters: ['json'], + ), + new Attribute( + key: 'resourceData', + type: ColumnType::String, + size: 131070, + required: true, + filters: ['json'], + ), + new Attribute( + key: 'errors', + type: ColumnType::String, + size: 1000000, + required: true, + array: true, + ), + new Attribute( + key: 'search', + type: ColumnType::String, + size: 16384, + ), + new Attribute( + key: 'resourceId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'resourceType', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), ], 'indexes' => [ - [ - '$id' => '_key_status', - 'type' => Database::INDEX_KEY, - 'attributes' => ['status'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => '_key_stage', - 'type' => Database::INDEX_KEY, - 'attributes' => ['stage'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => '_key_source', - 'type' => Database::INDEX_KEY, - 'attributes' => ['source'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => '_key_resource_id', - 'type' => Database::INDEX_KEY, - 'attributes' => ['resourceId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_DESC], - ], - [ - '$id' => ID::custom('_fulltext_search'), - 'type' => Database::INDEX_FULLTEXT, - 'attributes' => ['search'], - 'lengths' => [], - 'orders' => [], - ] + new Index( + key: '_key_status', + type: IndexType::Key, + attributes: ['status'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_stage', + type: IndexType::Key, + attributes: ['stage'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_source', + type: IndexType::Key, + attributes: ['source'], + lengths: [255], + orders: ['ASC'], + ), + new Index( + key: '_key_resource_id', + type: IndexType::Key, + attributes: ['resourceId'], + lengths: [255], + orders: ['DESC'], + ), + new Index( + key: '_fulltext_search', + type: IndexType::Fulltext, + attributes: ['search'], + ), ], ], - 'resourceTokens' => [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('resourceTokens'), + '$collection' => '_metadata', + '$id' => 'resourceTokens', 'name' => 'Resource Tokens', 'attributes' => [ - [ - '$id' => ID::custom('resourceId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('resourceInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('resourceType'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 100, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('secret'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 512, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => ['encrypt'], - ], - [ - '$id' => ID::custom('expire'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 255, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('accessedAt'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], + new Attribute( + key: 'resourceId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'resourceInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'resourceType', + type: ColumnType::String, + size: 100, + required: true, + ), + new Attribute( + key: 'secret', + type: ColumnType::String, + size: 512, + required: true, + filters: ['encrypt'], + ), + new Attribute( + key: 'expire', + type: ColumnType::Datetime, + size: Database::LENGTH_KEY, + filters: ['datetime'], + ), + new Attribute( + key: 'accessedAt', + type: ColumnType::Datetime, + signed: false, + filters: ['datetime'], + ), ], 'indexes' => [ - [ - '$id' => '_key_expiry_date', - 'type' => Database::INDEX_KEY, - 'attributes' => ['expire'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => '_key_accessedAt', - 'type' => Database::INDEX_KEY, - 'attributes' => ['accessedAt'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => '_key_resourceInternalId_resourceType', - 'type' => Database::INDEX_KEY, - 'attributes' => ['resourceInternalId', 'resourceType'], - 'lengths' => [], - 'orders' => [], - ], + new Index( + key: '_key_expiry_date', + type: IndexType::Key, + attributes: ['expire'], + orders: ['ASC'], + ), + new Index( + key: '_key_accessedAt', + type: IndexType::Key, + attributes: ['accessedAt'], + ), + new Index( + key: '_key_resourceInternalId_resourceType', + type: IndexType::Key, + attributes: ['resourceInternalId', 'resourceType'], + ), ], ], - 'transactions' => [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('transactions'), + '$collection' => '_metadata', + '$id' => 'transactions', 'name' => 'Transactions', 'attributes' => [ - [ - '$id' => ID::custom('status'), - 'type' => Database::VAR_STRING, - 'size' => 16, // pending | committing | committed | failed - 'signed' => true, - 'required' => false, - 'default' => 'pending', - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('operations'), - 'type' => Database::VAR_INTEGER, - 'size' => 0, - 'signed' => false, - 'required' => true, - 'default' => 0, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('expiresAt'), - 'type' => Database::VAR_DATETIME, - 'size' => 0, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], + new Attribute( + key: 'status', + type: ColumnType::String, + size: 16, + default: 'pending', + ), + new Attribute( + key: 'operations', + type: ColumnType::Integer, + required: true, + default: 0, + signed: false, + ), + new Attribute( + key: 'expiresAt', + type: ColumnType::Datetime, + required: true, + filters: ['datetime'], + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_key_expiresAt'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['expiresAt'], - 'lengths' => [], - 'orders' => [Database::ORDER_DESC], - ], + new Index( + key: '_key_expiresAt', + type: IndexType::Key, + attributes: ['expiresAt'], + orders: ['DESC'], + ), ], ], - 'transactionLogs' => [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('transactionLogs'), + '$collection' => '_metadata', + '$id' => 'transactionLogs', 'name' => 'Transaction Logs', 'attributes' => [ - [ - '$id' => ID::custom('transactionInternalId'), - 'type' => Database::VAR_STRING, - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('databaseInternalId'), - 'type' => Database::VAR_STRING, - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('collectionInternalId'), - 'type' => Database::VAR_STRING, - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('documentId'), - 'type' => Database::VAR_STRING, - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('action'), - 'type' => Database::VAR_STRING, - 'size' => 32, // create | update | upsert | increment | decrement | delete | bulkCreate | bulkUpdate | bulkUpsert | bulkDelete - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('data'), - 'type' => Database::VAR_STRING, - 'size' => 5_000_000, // Allow large payloads for bulk operations - 'signed' => false, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => ['json'], - ], + new Attribute( + key: 'transactionInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'databaseInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'collectionInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'documentId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + ), + new Attribute( + key: 'action', + type: ColumnType::String, + size: 32, + required: true, + ), + new Attribute( + key: 'data', + type: ColumnType::String, + size: 5000000, + required: true, + signed: false, + filters: ['json'], + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_key_transaction'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['transactionInternalId'], - 'lengths' => [], - 'orders' => [], - ], + new Index( + key: '_key_transaction', + type: IndexType::Key, + attributes: ['transactionInternalId'], + ), ], ], ]; diff --git a/app/config/collections/vectorsdb.php b/app/config/collections/vectorsdb.php index 817863cffa..5265aae285 100644 --- a/app/config/collections/vectorsdb.php +++ b/app/config/collections/vectorsdb.php @@ -1,165 +1,115 @@ [ - '$collection' => ID::custom('databases'), - '$id' => ID::custom('collections'), + '$collection' => 'databases', + '$id' => 'collections', 'name' => 'Collections', 'attributes' => [ - [ - '$id' => ID::custom('databaseInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('databaseId'), - 'type' => Database::VAR_STRING, - 'signed' => true, - 'size' => Database::LENGTH_KEY, - 'format' => '', - 'filters' => [], - 'required' => true, - 'default' => null, - 'array' => false, - ], - [ - '$id' => ID::custom('name'), - 'type' => Database::VAR_STRING, - 'size' => 256, - 'required' => true, - 'signed' => true, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('dimension'), - 'type' => Database::VAR_INTEGER, - 'size' => 0, - 'required' => true, - 'signed' => false, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('enabled'), - 'type' => Database::VAR_BOOLEAN, - 'signed' => true, - 'size' => 0, - 'format' => '', - 'filters' => [], - 'required' => true, - 'default' => null, - 'array' => false, - ], - [ - '$id' => ID::custom('documentSecurity'), - 'type' => Database::VAR_BOOLEAN, - 'signed' => true, - 'size' => 0, - 'format' => '', - 'filters' => [], - 'required' => true, - 'default' => null, - 'array' => false, - ], - [ - '$id' => ID::custom('attributes'), - 'type' => Database::VAR_STRING, - 'size' => 1000000, - 'required' => false, - 'signed' => true, - 'array' => false, - 'filters' => ['subQueryAttributes'], - ], - [ - '$id' => ID::custom('indexes'), - 'type' => Database::VAR_STRING, - 'size' => 1000000, - 'required' => false, - 'signed' => true, - 'array' => false, - 'filters' => ['subQueryIndexes'], - ], - [ - '$id' => ID::custom('search'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], + new Attribute( + key: 'databaseInternalId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'databaseId', + type: ColumnType::String, + size: Database::LENGTH_KEY, + required: true, + ), + new Attribute( + key: 'name', + type: ColumnType::String, + size: 256, + required: true, + ), + new Attribute( + key: 'dimension', + type: ColumnType::Integer, + required: true, + signed: false, + ), + new Attribute( + key: 'enabled', + type: ColumnType::Boolean, + required: true, + ), + new Attribute( + key: 'documentSecurity', + type: ColumnType::Boolean, + required: true, + ), + new Attribute( + key: 'attributes', + type: ColumnType::String, + size: 1000000, + filters: ['subQueryAttributes'], + ), + new Attribute( + key: 'indexes', + type: ColumnType::String, + size: 1000000, + filters: ['subQueryIndexes'], + ), + new Attribute( + key: 'search', + type: ColumnType::String, + size: 16384, + ), ], 'defaultAttributes' => [ - [ - '$id' => ID::custom('embeddings'), - 'type' => Database::VAR_VECTOR, - 'required' => true, - 'signed' => false, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('metadata'), - 'type' => Database::VAR_OBJECT, - 'default' => [], - 'required' => false, - 'size' => 0, - 'signed' => false, - 'array' => false, - 'filters' => [], - ], + new Attribute( + key: 'embeddings', + type: ColumnType::Vector, + required: true, + signed: false, + ), + new Attribute( + key: 'metadata', + type: ColumnType::Object, + default: [], + signed: false, + ), ], 'indexes' => [ - [ - '$id' => ID::custom('_fulltext_search'), - 'type' => Database::INDEX_FULLTEXT, - 'attributes' => ['search'], - 'lengths' => [], - 'orders' => [], - ], - [ - '$id' => ID::custom('_key_name'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['name'], - 'lengths' => [256], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_enabled'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['enabled'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_documentSecurity'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['documentSecurity'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], + new Index( + key: '_fulltext_search', + type: IndexType::Fulltext, + attributes: ['search'], + ), + new Index( + key: '_key_name', + type: IndexType::Key, + attributes: ['name'], + lengths: [256], + orders: ['ASC'], + ), + new Index( + key: '_key_enabled', + type: IndexType::Key, + attributes: ['enabled'], + orders: ['ASC'], + ), + new Index( + key: '_key_documentSecurity', + type: IndexType::Key, + attributes: ['documentSecurity'], + orders: ['ASC'], + ), ], 'defaultIndexes' => [ - // not creating default indexes on the embeddings as it depends on the type of query users using the most - [ - '$id' => ID::custom('_key_metadata'), - 'type' => Database::INDEX_OBJECT, - 'attributes' => ['metadata'], - 'lengths' => [], - 'orders' => [], - ], - ] - ] + new Index( + key: '_key_metadata', + type: IndexType::Object, + attributes: ['metadata'], + ), + ], + ], ]; diff --git a/app/http.php b/app/http.php index 517a1aa544..e7b34ae449 100644 --- a/app/http.php +++ b/app/http.php @@ -255,25 +255,8 @@ function createDatabase(Http $app, string $resourceKey, string $dbName, array $c continue; } - $attributes = array_map(fn ($attr) => new Document([ - '$id' => ID::custom($attr['$id']), - 'type' => $attr['type'], - 'size' => $attr['size'], - 'required' => $attr['required'], - 'signed' => $attr['signed'], - 'array' => $attr['array'], - 'filters' => $attr['filters'], - 'default' => $attr['default'] ?? null, - 'format' => $attr['format'] ?? '' - ]), $collection['attributes']); - - $indexes = array_map(fn ($index) => new Document([ - '$id' => ID::custom($index['$id']), - 'type' => $index['type'], - 'attributes' => $index['attributes'], - 'lengths' => $index['lengths'], - 'orders' => $index['orders'], - ]), $collection['indexes']); + $attributes = $collection['attributes']; + $indexes = $collection['indexes']; $database->createCollection($key, $attributes, $indexes); $collectionsCreated++; @@ -481,8 +464,8 @@ $http->on(Constant::EVENT_START, function (Server $http) use ($payloadSize, $tot continue; } - $attributes = \array_map(fn ($attribute) => new Document($attribute), $collection['attributes']); - $indexes = \array_map(fn (array $index) => new Document($index), $collection['indexes']); + $attributes = $collection['attributes']; + $indexes = $collection['indexes']; $dbForProject->createCollection($key, $attributes, $indexes); $collectionsCreated++; diff --git a/src/Appwrite/Migration/Migration.php b/src/Appwrite/Migration/Migration.php index a4f73eb5f2..2ca23331ab 100644 --- a/src/Appwrite/Migration/Migration.php +++ b/src/Appwrite/Migration/Migration.php @@ -5,6 +5,7 @@ namespace Appwrite\Migration; use Exception; use Utopia\Config\Config; use Utopia\Console; +use Utopia\Database\Attribute; use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Exception\Conflict; @@ -227,15 +228,8 @@ abstract class Migration $collection = $this->collections[$collectionType][$id]; - $attributes = []; - foreach ($collection['attributes'] as $attribute) { - $attributes[] = new Document($attribute); - } - - $indexes = []; - foreach ($collection['indexes'] as $index) { - $indexes[] = new Document($index); - } + $attributes = $collection['attributes']; + $indexes = $collection['indexes']; try { $this->dbForProject->createCollection($name, $attributes, $indexes); @@ -284,7 +278,7 @@ abstract class Migration $attributesToCreate = []; $attributes = $collection['attributes']; - $attributeKeys = \array_column($collection['attributes'], '$id'); + $attributeKeys = \array_map(fn ($a) => $a->key, $collection['attributes']); foreach ($attributeIds as $attributeId) { $attributeKey = \array_search($attributeId, $attributeKeys); @@ -293,12 +287,11 @@ abstract class Migration throw new Exception("Attribute {$attributeId} not found"); } - $attribute = $attributes[$attributeKey]; - $attribute['filters'] ??= []; - $attribute['default'] ??= null; - $attribute['default'] = \in_array('json', $attribute['filters']) - ? \json_encode($attribute['default']) - : $attribute['default']; + $attribute = clone $attributes[$attributeKey]; + + if (\in_array('json', $attribute->filters) && $attribute->default !== null) { + $attribute->default = \json_encode($attribute->default); + } $attributesToCreate[] = $attribute; } @@ -349,28 +342,21 @@ abstract class Migration $attributes = $collection['attributes']; - $attributeKey = \array_search($attributeId, \array_column($attributes, '$id')); + $attributeKey = \array_search($attributeId, \array_map(fn ($a) => $a->key, $attributes)); if ($attributeKey === false) { throw new Exception("Attribute {$attributeId} not found"); } - $attribute = $attributes[$attributeKey]; - $filters = $attribute['filters'] ?? []; - $default = $attribute['default'] ?? null; + $attribute = clone $attributes[$attributeKey]; + + if (\in_array('json', $attribute->filters) && $attribute->default !== null) { + $attribute->default = \json_encode($attribute->default); + } $database->createAttribute( collection: $collectionId, - id: $attributeId, - type: $attribute['type'], - size: $attribute['size'], - required: $attribute['required'], - default: \in_array('json', $filters) ? \json_encode($default) : $default, - signed: $attribute['signed'] ?? true, - array: $attribute['array'] ?? false, - format: $attribute['format'] ?? '', - formatOptions: $attribute['formatOptions'] ?? [], - filters: $filters, + attribute: $attribute, ); } @@ -407,21 +393,15 @@ abstract class Migration $indexes = $collection['indexes']; - $indexKey = \array_search($indexId, \array_column($indexes, '$id')); + $indexKey = \array_search($indexId, \array_map(fn ($i) => $i->key, $indexes)); if ($indexKey === false) { throw new Exception("Index {$indexId} not found"); } - $index = $indexes[$indexKey]; - $database->createIndex( collection: $collectionId, - id: $indexId, - type: $index['type'], - attributes: $index['attributes'], - lengths: $index['lengths'] ?? [], - orders: $index['orders'] ?? [] + index: $indexes[$indexKey], ); } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Create.php index 3585bc4477..40bf940a64 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Create.php @@ -216,15 +216,8 @@ class Create extends Action throw new Exception(Exception::GENERAL_SERVER_ERROR, 'The "collections" collection is not configured.'); } - $attributes = []; - foreach ($collections['attributes'] as $attribute) { - $attributes[] = new Document($attribute); - } - - $indexes = []; - foreach ($collections['indexes'] as $index) { - $indexes[] = new Document($index); - } + $attributes = $collections['attributes']; + $indexes = $collections['indexes']; try { $dbForProject->createCollection('database_' . $database->getSequence(), $attributes, $indexes); diff --git a/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Create.php index b85a8b30b4..175625c253 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Create.php @@ -12,6 +12,7 @@ use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Database\Validator\CustomId; use Appwrite\Utopia\Response as UtopiaResponse; use Utopia\Config\Config; +use Utopia\Database\Attribute; use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Exception\Duplicate as DuplicateException; @@ -117,18 +118,15 @@ class Create extends CollectionAction /** @var Database $dbForDatabases */ $dbForDatabases = $getDatabasesDB($database); - $attributes = []; - $indexes = []; $collections = (Config::getParam('collections', [])['vectorsdb'] ?? [])['collections'] ?? []; - foreach ($collections['defaultAttributes'] as $attribute) { - if ($attribute['$id'] === 'embeddings') { - $attribute['size'] = $dimension; + $attributes = \array_map(function (Attribute $attribute) use ($dimension) { + if ($attribute->key === 'embeddings') { + $attribute = clone $attribute; + $attribute->size = $dimension; } - $attributes[] = new Document($attribute); - } - foreach ($collections['defaultIndexes'] as $index) { - $indexes[] = new Document($index); - } + return $attribute; + }, $collections['defaultAttributes']); + $indexes = $collections['defaultIndexes']; try { // passing null in creates only creates the metadata collection if (!$dbForDatabases->exists(null, Database::METADATA)) { diff --git a/src/Appwrite/Platform/Modules/Projects/Http/Projects/Create.php b/src/Appwrite/Platform/Modules/Projects/Http/Projects/Create.php index eb71e5a02f..634de3dc80 100644 --- a/src/Appwrite/Platform/Modules/Projects/Http/Projects/Create.php +++ b/src/Appwrite/Platform/Modules/Projects/Http/Projects/Create.php @@ -270,8 +270,8 @@ class Create extends Action continue; } - $attributes = \array_map(fn ($attribute) => new Document($attribute), $collection['attributes']); - $indexes = \array_map(fn (array $index) => new Document($index), $collection['indexes']); + $attributes = $collection['attributes']; + $indexes = $collection['indexes']; try { $dbForProject->createCollection($key, $attributes, $indexes); diff --git a/tests/unit/General/CollectionsTest.php b/tests/unit/General/CollectionsTest.php index 73a9ccd0c2..b30ffe8450 100644 --- a/tests/unit/General/CollectionsTest.php +++ b/tests/unit/General/CollectionsTest.php @@ -21,7 +21,7 @@ class CollectionsTest extends TestCase foreach ($collection['attributes'] as $check) { $occurrences = 0; foreach ($collection['attributes'] as $attribute) { - if ($attribute['$id'] == $check['$id']) { + if ($attribute->key == $check->key) { $occurrences++; } }