Skip to content

Commit

Permalink
Database structure update
Browse files Browse the repository at this point in the history
  • Loading branch information
getpinga committed Oct 24, 2024
1 parent 166ad44 commit 338c8a1
Showing 1 changed file with 182 additions and 11 deletions.
193 changes: 182 additions & 11 deletions whmcs_registrar/whmcs_registrar.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function whmcs_registrar_config() {
return [
'name' => 'ICANN Registrar Accreditation',
'description' => 'Module for Implementing ICANN Accreditation Database Structure',
'author' => 'Namingo',
'author' => 'Namingo Team',
'version' => '1.0',
];
}
Expand All @@ -24,8 +24,171 @@ function whmcs_registrar_config() {
function whmcs_registrar_activate() {
try {
$sql = "
-- Domain TLD Table
CREATE TABLE IF NOT EXISTS `namingo_domain_tld` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`tld` varchar(32) NOT NULL,
`idn_table` varchar(255) NOT NULL,
`secure` TINYINT UNSIGNED NOT NULL,
`launch_phase_id` INT DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `tld` (`tld`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Contact Table
CREATE TABLE IF NOT EXISTS `namingo_contact` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`identifier` varchar(255) NOT NULL,
`voice` varchar(17) default NULL,
`voice_x` int(10) default NULL,
`fax` varchar(17) default NULL,
`fax_x` int(10) default NULL,
`email` varchar(255) NOT NULL,
`nin` varchar(255) default NULL,
`nin_type` enum('personal','business') default NULL,
`clid` int(10) unsigned NOT NULL,
`crid` int(10) unsigned NOT NULL,
`crdate` datetime(3) NOT NULL,
`upid` int(10) unsigned default NULL,
`lastupdate` datetime(3) default NULL,
`trdate` datetime(3) default NULL,
`trstatus` enum('clientApproved','clientCancelled','clientRejected','pending','serverApproved','serverCancelled') default NULL,
`reid` int(10) unsigned default NULL,
`redate` datetime(3) default NULL,
`acid` int(10) unsigned default NULL,
`acdate` datetime(3) default NULL,
`disclose_voice` enum('0','1') NOT NULL default '1',
`disclose_fax` enum('0','1') NOT NULL default '1',
`disclose_email` enum('0','1') NOT NULL default '1',
`validation` enum('0','1','2','3','4'),
`validation_stamp` datetime(3) default NULL,
`validation_log` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `identifier` (`identifier`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Contact Postalinfo Table
CREATE TABLE IF NOT EXISTS `namingo_contact_postalInfo` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`contact_id` int(10) unsigned NOT NULL,
`type` enum('int','loc') NOT NULL default 'int',
`name` varchar(255) NOT NULL,
`org` varchar(255) default NULL,
`street1` varchar(255) default NULL,
`street2` varchar(255) default NULL,
`street3` varchar(255) default NULL,
`city` varchar(255) NOT NULL,
`sp` varchar(255) default NULL,
`pc` varchar(16) default NULL,
`cc` char(2) NOT NULL,
`disclose_name_int` enum('0','1') NOT NULL default '1',
`disclose_name_loc` enum('0','1') NOT NULL default '1',
`disclose_org_int` enum('0','1') NOT NULL default '1',
`disclose_org_loc` enum('0','1') NOT NULL default '1',
`disclose_addr_int` enum('0','1') NOT NULL default '1',
`disclose_addr_loc` enum('0','1') NOT NULL default '1',
PRIMARY KEY (`id`),
UNIQUE KEY `uniquekey` (`contact_id`,`type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Domain Table
CREATE TABLE IF NOT EXISTS `namingo_domain` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(68) NOT NULL,
`tldid` int(10) unsigned NOT NULL,
`registrant` int(10) unsigned default NULL,
`crdate` datetime(3) NOT NULL,
`exdate` datetime(3) NOT NULL,
`lastupdate` datetime(3) default NULL,
`clid` int(10) unsigned NOT NULL,
`crid` int(10) unsigned NOT NULL,
`upid` int(10) unsigned default NULL,
`trdate` datetime(3) default NULL,
`trstatus` enum('clientApproved','clientCancelled','clientRejected','pending','serverApproved','serverCancelled') default NULL,
`reid` int(10) unsigned default NULL,
`redate` datetime(3) default NULL,
`acid` int(10) unsigned default NULL,
`acdate` datetime(3) default NULL,
`transfer_exdate` datetime(3) default NULL,
`idnlang` varchar(16) default NULL,
`delTime` datetime(3) default NULL,
`resTime` datetime(3) default NULL,
`rgpstatus` enum('addPeriod','autoRenewPeriod','renewPeriod','transferPeriod','pendingDelete','pendingRestore','redemptionPeriod') default NULL,
`rgppostData` text default NULL,
`rgpdelTime` datetime(3) default NULL,
`rgpresTime` datetime(3) default NULL,
`rgpresReason` text default NULL,
`rgpstatement1` text default NULL,
`rgpstatement2` text default NULL,
`rgpother` text default NULL,
`addPeriod` tinyint(3) unsigned default NULL,
`autoRenewPeriod` tinyint(3) unsigned default NULL,
`renewPeriod` tinyint(3) unsigned default NULL,
`transferPeriod` tinyint(3) unsigned default NULL,
`renewedDate` datetime(3) default NULL,
`agp_exempted` tinyint(1) DEFAULT 0,
`agp_request` datetime(3) default NULL,
`agp_grant` datetime(3) default NULL,
`agp_reason` text default NULL,
`agp_status` varchar(30) default NULL,
`tm_notice_accepted` datetime(3) default NULL,
`tm_notice_expires` datetime(3) default NULL,
`tm_notice_id` varchar(150) default NULL,
`tm_notice_validator` varchar(30) default NULL,
`tm_smd_id` text default NULL,
`tm_phase` TEXT NOT NULL DEFAULT 'NONE',
`phase_name` VARCHAR(75) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Domain Contact Map Table
CREATE TABLE IF NOT EXISTS `namingo_domain_contact_map` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`domain_id` int(10) unsigned NOT NULL,
`contact_id` int(10) unsigned NOT NULL,
`type` enum('admin','billing','tech') NOT NULL default 'admin',
PRIMARY KEY (`id`),
UNIQUE KEY `uniquekey` (`domain_id`,`contact_id`,`type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Host Table
CREATE TABLE IF NOT EXISTS `namingo_host` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`domain_id` int(10) unsigned default NULL,
`clid` int(10) unsigned NOT NULL,
`crid` int(10) unsigned NOT NULL,
`crdate` datetime(3) NOT NULL,
`upid` int(10) unsigned default NULL,
`lastupdate` datetime(3) default NULL,
`trdate` datetime(3) default NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Domain Host Map Table
CREATE TABLE IF NOT EXISTS `namingo_domain_host_map` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`domain_id` int(10) unsigned NOT NULL,
`host_id` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `domain_host_map_id` (`domain_id`,`host_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Host Address Table
CREATE TABLE IF NOT EXISTS `namingo_host_addr` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`host_id` int(10) unsigned NOT NULL,
`addr` varchar(45) NOT NULL,
`ip` enum('v4','v6') NOT NULL default 'v4',
PRIMARY KEY (`id`),
UNIQUE KEY `unique` (`host_id`,`addr`,`ip`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Domain Meta Table
CREATE TABLE IF NOT EXISTS `domain_meta` (
CREATE TABLE IF NOT EXISTS `namingo_domain_meta` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`domain_id` int(10) NOT NULL,
`registry_domain_id` varchar(100) DEFAULT NULL,
Expand All @@ -40,21 +203,21 @@ function whmcs_registrar_activate() {
PRIMARY KEY (`id`),
UNIQUE KEY `domain_id` (`domain_id`),
CONSTRAINT `domain_meta_ibfk_1` FOREIGN KEY (`domain_id`) REFERENCES `tbldomains`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Domain Status Table
CREATE TABLE IF NOT EXISTS `domain_status` (
CREATE TABLE IF NOT EXISTS `namingo_domain_status` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`domain_id` int(10) NOT NULL,
`status` varchar(100) NOT NULL,
`created_at` datetime DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `domain_status_unique` (`domain_id`, `status`),
CONSTRAINT `domain_status_ibfk_1` FOREIGN KEY (`domain_id`) REFERENCES `tbldomains`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- DNSSEC Table
CREATE TABLE IF NOT EXISTS `domain_dnssec` (
CREATE TABLE IF NOT EXISTS `namingo_domain_dnssec` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`domain_id` int(10) NOT NULL,
`key_tag` int(11) NOT NULL,
Expand All @@ -65,7 +228,7 @@ function whmcs_registrar_activate() {
PRIMARY KEY (`id`),
UNIQUE KEY `key_tag` (`key_tag`),
CONSTRAINT `domain_dnssec_ibfk_1` FOREIGN KEY (`domain_id`) REFERENCES `tbldomains`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
";

Capsule::unprepared($sql);
Expand All @@ -87,10 +250,18 @@ function whmcs_registrar_activate() {
*/
function whmcs_registrar_deactivate() {
try {
Capsule::schema()->dropIfExists('domain_dnssec');
Capsule::schema()->dropIfExists('domain_status');
Capsule::schema()->dropIfExists('domain_meta');

Capsule::schema()->dropIfExists('namingo_domain_tld');
Capsule::schema()->dropIfExists('namingo_contact');
Capsule::schema()->dropIfExists('namingo_contact_postalInfo');
Capsule::schema()->dropIfExists('namingo_domain');
Capsule::schema()->dropIfExists('namingo_domain_contact_map');
Capsule::schema()->dropIfExists('namingo_host');
Capsule::schema()->dropIfExists('namingo_domain_host_map');
Capsule::schema()->dropIfExists('namingo_host_addr');
Capsule::schema()->dropIfExists('namingo_domain_dnssec');
Capsule::schema()->dropIfExists('namingo_domain_status');
Capsule::schema()->dropIfExists('namingo_domain_meta');

return [
'status' => 'success',
'description' => 'Module deactivated successfully.',
Expand Down

0 comments on commit 338c8a1

Please sign in to comment.