sudo87 commented on code in PR #12737:
URL: https://github.com/apache/cloudstack/pull/12737#discussion_r3063587546


##########
engine/schema/src/main/resources/META-INF/db/schema-42210to42300.sql:
##########
@@ -117,3 +117,76 @@ CALL 
`cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.vpc_offerings','conserve_mode', 'tin
 
 --- Disable/enable NICs
 CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.nics','enabled', 'TINYINT(1) NOT 
NULL DEFAULT 1 COMMENT ''Indicates whether the NIC is enabled or not'' ');
+
+
+-- ======================================================================
+-- DNS Framework Schema
+-- ======================================================================
+
+-- DNS Server Table (Stores DNS Server Configurations)
+CREATE TABLE `cloud`.`dns_server` (
+    `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id of the dns 
server',
+    `uuid` varchar(40) COMMENT 'uuid of the dns server',
+    `name` varchar(255) NOT NULL COMMENT 'display name of the dns server',
+    `provider_type` varchar(255) NOT NULL COMMENT 'Provider type such as 
PowerDns',
+    `url` varchar(1024) NOT NULL COMMENT 'dns server url',
+    `dns_username` varchar(255) COMMENT 'username or email for dns server 
credentials',
+    `api_key` varchar(255) NOT NULL COMMENT 'dns server api_key',
+    `external_server_id` varchar(255) COMMENT 'dns server id e.g. localhost 
for powerdns',
+    `port` int(11) DEFAULT NULL COMMENT 'optional dns server port',
+    `name_servers` varchar(1024) DEFAULT NULL COMMENT 'Comma separated list of 
name servers',
+    `is_public` tinyint(1) NOT NULL DEFAULT '0',
+    `public_domain_suffix` VARCHAR(255),
+    `state` ENUM('Enabled', 'Disabled') NOT NULL DEFAULT 'Disabled',
+    `domain_id` bigint unsigned COMMENT 'for domain-specific ownership',
+    `account_id` bigint(20) unsigned NOT NULL,
+    `created` datetime NOT NULL COMMENT 'date created',
+    `removed` datetime DEFAULT NULL COMMENT 'Date removed (soft delete)',
+    PRIMARY KEY (`id`),
+    KEY `i_dns_server__account_id` (`account_id`),
+    CONSTRAINT `fk_dns_server__account_id` FOREIGN KEY (`account_id`) 
REFERENCES `account` (`id`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+-- DNS Zone Table (Stores DNS Zone Metadata)
+CREATE TABLE `cloud`.`dns_zone` (
+    `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id of the dns zone',
+    `uuid` varchar(40) COMMENT 'uuid of the dns zone',
+    `name` varchar(255) NOT NULL COMMENT 'dns zone name (e.g. example.com)',
+    `dns_server_id` bigint unsigned NOT NULL COMMENT 'fk to dns_server.id',
+    `external_reference` VARCHAR(255) COMMENT 'id of external provider 
resource',
+    `domain_id` bigint unsigned COMMENT 'for domain-specific ownership',
+    `account_id` bigint unsigned COMMENT 'account id. foreign key to account 
table',
+    `description` varchar(1024) DEFAULT NULL,
+    `type` ENUM('Private', 'Public') NOT NULL DEFAULT 'Public',
+    `state` ENUM('Active', 'Inactive') NOT NULL DEFAULT 'Inactive',
+    `created` datetime NOT NULL COMMENT 'date created',
+    `removed` datetime DEFAULT NULL COMMENT 'Date removed (soft delete)',
+    PRIMARY KEY (`id`),
+    CONSTRAINT `uc_dns_zone__uuid` UNIQUE (`uuid`),
+    KEY `i_dns_zone__dns_server` (`dns_server_id`),
+    KEY `i_dns_zone__account_id` (`account_id`),
+    CONSTRAINT `fk_dns_zone__dns_server_id` FOREIGN KEY (`dns_server_id`) 
REFERENCES `dns_server` (`id`) ON DELETE CASCADE,
+    CONSTRAINT `fk_dns_zone__account_id` FOREIGN KEY (`account_id`) REFERENCES 
`account` (`id`) ON DELETE CASCADE,
+    CONSTRAINT `fk_dns_zone__domain_id` FOREIGN KEY (`domain_id`) REFERENCES 
`domain` (`id`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+-- DNS Zone Network Map (One-to-Many Link)
+CREATE TABLE `cloud`.`dns_zone_network_map` (
+  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id of the dns zone to 
network mapping',
+  `uuid` varchar(40),
+  `dns_zone_id` bigint(20) unsigned NOT NULL,
+  `network_id` bigint(20) unsigned NOT NULL COMMENT 'network to which dns zone 
is associated to',
+  `sub_domain` varchar(255) DEFAULT NULL COMMENT 'Subdomain for 
auto-registration',
+  `created` datetime NOT NULL COMMENT 'date created',
+  `removed` datetime DEFAULT NULL COMMENT 'Date removed (soft delete)',
+  PRIMARY KEY (`id`),
+  CONSTRAINT `uc_dns_zone__uuid` UNIQUE (`uuid`),
+  KEY `fk_dns_map__zone_id` (`dns_zone_id`),
+  KEY `fk_dns_map__network_id` (`network_id`),
+  CONSTRAINT `fk_dns_map__zone_id` FOREIGN KEY (`dns_zone_id`) REFERENCES 
`dns_zone` (`id`) ON DELETE CASCADE,
+  CONSTRAINT `fk_dns_map__network_id` FOREIGN KEY (`network_id`) REFERENCES 
`networks` (`id`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+-- Set default limit to 10 DNS zones for standard Accounts
+INSERT INTO `cloud`.`configuration` (`category`, `instance`, `component`, 
`name`, `value`, `description`, `default_value`)
+VALUES ('Advanced', 'DEFAULT', 'ResourceLimitManager', 
'max.account.dns_zones', '10', 'The default maximum number of DNS zones that 
can be created by an Account', '10');

Review Comment:
   We can enforce limits per project/domain. I wasn't sure if it would make 
sense to put it at project or domain level. 
   
   We can revisit this in next phase during resource limit enforcement.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to