get_charset_collate(); $prefix = $wpdb->prefix; $queries = array( "CREATE TABLE {$prefix}" . TableNames::DOCUMENTS . " ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT, uuid char(36) NOT NULL, order_id bigint(20) unsigned NOT NULL, snapshot_id bigint(20) unsigned NULL, document_type varchar(64) NOT NULL, revision int(10) unsigned NOT NULL DEFAULT 1, template_version_id bigint(20) unsigned NULL, legal_text_version_id bigint(20) unsigned NULL, terms_version_id bigint(20) unsigned NULL, language_code varchar(16) NOT NULL DEFAULT 'bs', storage_key varchar(255) NULL, mime_type varchar(128) NOT NULL DEFAULT 'application/pdf', file_hash char(64) NULL, file_size bigint(20) unsigned NULL, status varchar(32) NOT NULL, supersedes_document_id bigint(20) unsigned NULL, snapshot_hash char(64) NULL, template_hash char(64) NULL, legal_text_hash char(64) NULL, terms_hash char(64) NULL, input_manifest_json longtext NULL, input_hash char(64) NULL, sealed_at datetime NULL, created_at datetime NOT NULL, PRIMARY KEY (id), UNIQUE KEY uuid (uuid), UNIQUE KEY snapshot_type_revision (snapshot_id,document_type,revision), UNIQUE KEY order_type_revision (order_id,document_type,revision), KEY order_id (order_id), KEY snapshot_id (snapshot_id) ) {$collate};", "CREATE TABLE {$prefix}" . TableNames::TEMPLATE_VERSIONS . " ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT, uuid char(36) NOT NULL, template_key varchar(96) NOT NULL, version int(10) unsigned NOT NULL, origin varchar(32) NOT NULL, layout_json longtext NULL, template_html longtext NOT NULL, template_css longtext NULL, semantic_manifest longtext NULL, content_hash char(64) NOT NULL, status varchar(32) NOT NULL, effective_from datetime NULL, effective_until datetime NULL, created_at datetime NOT NULL, published_at datetime NULL, PRIMARY KEY (id), UNIQUE KEY uuid (uuid), UNIQUE KEY template_version (template_key,version), KEY template_effective (template_key,status,effective_from) ) {$collate};", "CREATE TABLE {$prefix}" . TableNames::LEGAL_TEXT_VERSIONS . " ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT, uuid char(36) NOT NULL, text_set_key varchar(96) NOT NULL, language_code varchar(16) NOT NULL, version int(10) unsigned NOT NULL, origin varchar(32) NOT NULL, ruleset_reference varchar(191) NULL, content_json longtext NOT NULL, content_hash char(64) NOT NULL, status varchar(32) NOT NULL, effective_from datetime NULL, effective_until datetime NULL, legal_review_json longtext NULL, created_at datetime NOT NULL, published_at datetime NULL, PRIMARY KEY (id), UNIQUE KEY uuid (uuid), UNIQUE KEY set_lang_version (text_set_key,language_code,version), KEY legal_text_effective (text_set_key,language_code,status,effective_from) ) {$collate};", ); foreach ( $queries as $query ) { dbDelta( $query ); } return true; } }