prefix.DB::$namespace.'_url_shorteners'; } public function __construct() { parent::__construct(); $this->table_name = $this->prefix.'_url_shorteners'; $this->primary_key = 'id'; $this->version = '1.0'; } public function sql_create() { return "CREATE TABLE {$this->table_name} ( id bigint(20) NOT NULL AUTO_INCREMENT, tenant_id bigint(20) NOT NULL, short_code varchar(10) NOT NULL, original_url text NOT NULL, expires_at datetime DEFAULT NULL, visits int DEFAULT 0, last_visit datetime DEFAULT NULL, date_created datetime NOT NULL, date_modified datetime NOT NULL, PRIMARY KEY (id), UNIQUE KEY `shorteners_short_code_unique` (`short_code`), KEY `shorteners_tenant_id_foreign` (`tenant_id`), CONSTRAINT `shorteners_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `{$this->prefix}_restaurants` (`id`) ON DELETE CASCADE )"; } } SRR_DB_Url_Shorteners::init();