-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstaller.php
31 lines (27 loc) · 1.21 KB
/
installer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
global $wpdb;
$table = new Clp_Link();
$tableName = $table->getTableName();
$computeLinksDbVersion = '1.0.0';
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$tableName}'" ) != $tableName ) {
$sql = sprintf("CREATE TABLE %s (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`created_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`user_id` int(10) unsigned NOT NULL,
`url` varchar(400) COLLATE utf8_persian_ci NOT NULL,
`md5_url` varchar(32) COLLATE utf8_persian_ci NOT NULL,
`size` int(50) unsigned DEFAULT 0,
`type` varchar(10) COLLATE utf8_persian_ci DEFAULT 'NULL',
`host` varchar(40) COLLATE utf8_persian_ci NOT NULL,
`title` varchar(100) COLLATE utf8_persian_ci DEFAULT 'NULL',
`post_id` int(20) unsigned DEFAULT NULL,
`count` mediumint(9) DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY `url_postId` (`md5_url`,`post_id`),
KEY `md5_url` (`md5_url`),
KEY `post_id` (`post_id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_persian_ci;", $tableName);
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( $sql );
add_option( 'my_db_version', $computeLinksDbVersion );
}