links_table() ); dbDelta( $this->uses_table() ); dbDelta( $this->fixes_table() ); } public function drop(): void { $tables = array( $this->tables->links(), $this->tables->uses(), $this->tables->fixes(), ); foreach ( $tables as $table ) { $this->query_runner->execute( 'DROP TABLE IF EXISTS ' . $table ); } } private function links_table(): string { return 'CREATE TABLE ' . $this->tables->links() . " ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT, url text NOT NULL, url_hash char(32) NOT NULL, host varchar(255) NOT NULL DEFAULT '', kind varchar(10) NOT NULL DEFAULT 'link', internal tinyint(1) NOT NULL DEFAULT 0, verdict varchar(10) NOT NULL DEFAULT 'new', reason varchar(20) NULL, http_code smallint(5) NULL, final_url text NULL, streak int(10) unsigned NOT NULL DEFAULT 0, failures int(10) unsigned NOT NULL DEFAULT 0, since bigint(20) NULL, checked_at bigint(20) NULL, check_after bigint(20) NOT NULL DEFAULT 0, outcome varchar(10) NOT NULL DEFAULT 'listed', fixed_by bigint(20) NULL, redirect_to text NULL, PRIMARY KEY (id), UNIQUE KEY url_hash (url_hash), KEY check_after (check_after), KEY verdict (verdict) ) " . $this->charset_collate . ';'; } private function uses_table(): string { return 'CREATE TABLE ' . $this->tables->uses() . ' ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT, link_id bigint(20) unsigned NOT NULL, post_id bigint(20) unsigned NOT NULL, text text NOT NULL, before_text text NOT NULL, after_text text NOT NULL, PRIMARY KEY (id), KEY link_id (link_id), KEY post_id (post_id) ) ' . $this->charset_collate . ';'; } private function fixes_table(): string { return 'CREATE TABLE ' . $this->tables->fixes() . ' ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT, action varchar(10) NOT NULL, state varchar(10) NOT NULL, created_at bigint(20) NOT NULL, new_url text NULL, links_total int(10) unsigned NOT NULL DEFAULT 0, links_done int(10) unsigned NOT NULL DEFAULT 0, places_total int(10) unsigned NOT NULL DEFAULT 0, places_done int(10) unsigned NOT NULL DEFAULT 0, places_failed int(10) unsigned NOT NULL DEFAULT 0, first_url text NOT NULL, link_ids longtext NOT NULL, journal longtext NOT NULL, PRIMARY KEY (id), KEY created_at (created_at) ) ' . $this->charset_collate . ';'; } }