From a23548fba5bb89ca7ed6d053099533bb291fa9c6 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 16 May 2025 14:57:18 +1200 Subject: [PATCH] Add domains + dnsRecords to platform --- app/config/collections/platform.php | 368 +++++++++++++++++++++++++++- 1 file changed, 366 insertions(+), 2 deletions(-) diff --git a/app/config/collections/platform.php b/app/config/collections/platform.php index 84f0731443..4836f566aa 100644 --- a/app/config/collections/platform.php +++ b/app/config/collections/platform.php @@ -225,7 +225,7 @@ return [ '$id' => ID::custom('templates'), 'type' => Database::VAR_STRING, 'format' => '', - 'size' => 1000000, // TODO make sure size fits + 'size' => 1_000_000, // TODO make sure size fits 'signed' => true, 'required' => false, 'default' => [], @@ -1890,5 +1890,369 @@ return [ 'name' => 'vcsCommentLocks', 'attributes' => [], 'indexes' => [] - ] + ], + + 'domains' => [ + '$collection' => ID::custom(Database::METADATA), + '$id' => ID::custom('domains'), + 'name' => 'Domains', + '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('domain'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 255, + 'signed' => true, + 'required' => true, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => ID::custom('registrar'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => false, + 'default' => null, // e.g. "appwrite" or "third_party" + 'array' => false, + 'filters' => [], + ], + [ + '$id' => ID::custom('nameservers'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 255, + 'signed' => true, + 'required' => false, + 'default' => '', // "Appwrite" or empty string + 'array' => false, + 'filters' => [], + ], + [ + '$id' => ID::custom('expire'), + 'type' => Database::VAR_DATETIME, + 'format' => '', + 'size' => 0, + 'signed' => false, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => ['datetime'], + ], + [ + '$id' => ID::custom('renewal'), + 'type' => Database::VAR_DATETIME, + 'format' => '', + 'size' => 0, + 'signed' => false, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => ['datetime'], + ], + [ + '$id' => ID::custom('autoRenewal'), + 'type' => Database::VAR_BOOLEAN, + 'signed' => true, + 'size' => 0, + 'format' => '', + 'filters' => [], + 'required' => false, + 'default' => false, + 'array' => false, + ], + [ + '$id' => ID::custom('renewalPrice'), + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => false, + 'required' => false, + 'default' => 0, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => ID::custom('search'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + ], + 'indexes' => [ + [ + '$id' => ID::custom('_key_search'), + 'type' => Database::INDEX_FULLTEXT, + 'attributes' => ['search'], + 'lengths' => [], + 'orders' => [], + ], + [ + '$id' => ID::custom('_key_teamInternalId'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['teamInternalId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => ID::custom('_key_domain'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['domain'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => ID::custom('_key_teamId_domain'), + 'type' => Database::INDEX_UNIQUE, + 'attributes' => ['teamId', 'domain'], + 'lengths' => [], + 'orders' => [], + ], + [ + '$id' => ID::custom('_key_expire'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['expire'], + 'lengths' => [], + 'orders' => [], + ], + [ + '$id' => ID::custom('_key_registrar'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['registrar'], + 'lengths' => [], + 'orders' => [], + ], + [ + '$id' => ID::custom('_key_nameservers'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['nameservers'], + 'lengths' => [], + 'orders' => [], + ], + [ + '$id' => ID::custom('_key_renewalPrice'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['renewalPrice'], + 'lengths' => [], + 'orders' => [], + ], + [ + '$id' => ID::custom('_key_renewal'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['renewal'], + 'lengths' => [], + 'orders' => [], + ], + [ + '$id' => ID::custom('_key_autoRenewal'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['autoRenewal'], + 'lengths' => [], + 'orders' => [], + ], + ], + ], + + 'dnsRecords' => [ + '$collection' => ID::custom(Database::METADATA), + '$id' => ID::custom('dnsRecords'), + 'name' => 'DNS Records', + 'attributes' => [ + [ + '$id' => ID::custom('domainInternalId'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => true, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => ID::custom('domainId'), + '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' => true, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => ID::custom('name'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 255, + 'signed' => true, + 'required' => true, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => ID::custom('value'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, + 'required' => true, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => ID::custom('ttl'), + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => 3600, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => ID::custom('priority'), + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => 0, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => ID::custom('weight'), + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => 0, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => ID::custom('port'), + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => false, // Port numbers are always positive + 'required' => false, + 'default' => 0, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => ID::custom('lock'), + 'type' => Database::VAR_BOOLEAN, + 'signed' => true, + 'size' => 0, + 'format' => '', + 'filters' => [], + 'required' => false, + 'default' => false, + 'array' => false, + ], + [ + '$id' => ID::custom('comment'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, + 'required' => true, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + ], + 'indexes' => [ + [ + '$id' => ID::custom('_key_domainInternalId'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['domainInternalId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => ID::custom('_key_domainId'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['domainId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + // New indexes based on allowed query attributes + [ + '$id' => ID::custom('_key_type'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['type'], + 'lengths' => [], + 'orders' => [], + ], + [ + '$id' => ID::custom('_key_name'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['name'], + 'lengths' => [], + 'orders' => [], + ], + [ + '$id' => ID::custom('_key_lock'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['lock'], + 'lengths' => [], + 'orders' => [], + ], + [ + '$id' => ID::custom('_key_priority'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['priority'], + 'lengths' => [], + 'orders' => [], + ], + ], + ], ];