Skip to content

Commit d4edd85

Browse files
committed
Update table creation SQL
Make all fields NOT NULL with defaults Fix primary key error Make id field signed
1 parent 355283e commit d4edd85

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

includes/db.php

+9-12
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ function create_code_snippets_table( $table_name ) {
101101
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
102102

103103
/* Set the database charset */
104-
105104
$charset_collate = '';
106105

107106
if ( ! empty( $wpdb->charset ) ) {
@@ -113,19 +112,17 @@ function create_code_snippets_table( $table_name ) {
113112
}
114113

115114
/* Create the database table */
116-
117115
$sql = "CREATE TABLE $table_name (
118-
id bigint(20) unsigned not null auto_increment,
119-
name tinytext not null,
120-
description text,
121-
code longtext not null,
122-
tags longtext,
123-
scope tinyint(1) default 0,
124-
active tinyint(1) not null default 0,
125-
primary key (id)
126-
) {$charset_collate};";
116+
id bigint(20) NOT NULL AUTO_INCREMENT,
117+
name tinytext NOT NULL default '',
118+
description text NOT NULL default '',
119+
code longtext NOT NULL default '',
120+
tags longtext NOT NULL default '',
121+
scope tinyint(1) NOT NULL default 0,
122+
active tinyint(1) NOT NULL default 0,
123+
PRIMARY KEY (id)
124+
) $charset_collate;";
127125

128126
dbDelta( $sql );
129-
130127
do_action( 'code_snippets/create_table', $table_name );
131128
}

0 commit comments

Comments
 (0)