mirror of
https://github.com/haiwen/ccnet-server.git
synced 2025-06-26 05:31:34 +00:00
Create index for 'path' in GroupStructure.
This commit is contained in:
parent
d8937ae5ad
commit
9148bc18f4
@ -130,7 +130,7 @@ static int check_db_table (CcnetGroupManager *manager, CcnetDB *db)
|
|||||||
|
|
||||||
sql = "CREATE TABLE IF NOT EXISTS GroupStructure ( "
|
sql = "CREATE TABLE IF NOT EXISTS GroupStructure ( "
|
||||||
"id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT, group_id INTEGER, "
|
"id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT, group_id INTEGER, "
|
||||||
"path VARCHAR(1024), UNIQUE INDEX(group_id))ENGINE=INNODB";
|
"path VARCHAR(1024), UNIQUE INDEX(group_id), UNIQUE INDEX(path))ENGINE=INNODB";
|
||||||
if (ccnet_db_query (db, sql) < 0)
|
if (ccnet_db_query (db, sql) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
} else if (db_type == CCNET_DB_TYPE_SQLITE) {
|
} else if (db_type == CCNET_DB_TYPE_SQLITE) {
|
||||||
@ -168,6 +168,12 @@ static int check_db_table (CcnetGroupManager *manager, CcnetDB *db)
|
|||||||
"path VARCHAR(1024))";
|
"path VARCHAR(1024))";
|
||||||
if (ccnet_db_query (db, sql) < 0)
|
if (ccnet_db_query (db, sql) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
sql = "CREATE UNIQUE INDEX IF NOT EXISTS path_indx on "
|
||||||
|
"`GroupStructure` (`path`)";
|
||||||
|
if (ccnet_db_query (db, sql) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
} else if (db_type == CCNET_DB_TYPE_PGSQL) {
|
} else if (db_type == CCNET_DB_TYPE_PGSQL) {
|
||||||
g_string_printf (group_sql,
|
g_string_printf (group_sql,
|
||||||
"CREATE TABLE IF NOT EXISTS \"%s\" (group_id SERIAL"
|
"CREATE TABLE IF NOT EXISTS \"%s\" (group_id SERIAL"
|
||||||
@ -200,6 +206,13 @@ static int check_db_table (CcnetGroupManager *manager, CcnetDB *db)
|
|||||||
"path VARCHAR(1024))";
|
"path VARCHAR(1024))";
|
||||||
if (ccnet_db_query (db, sql) < 0)
|
if (ccnet_db_query (db, sql) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
if (!pgsql_index_exists (db, "structure_path_idx")) {
|
||||||
|
sql = "CREATE UNIQUE structure_path_idx ON GroupStructure (path)";
|
||||||
|
if (ccnet_db_query (db, sql) < 0)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
g_string_free (group_sql, TRUE);
|
g_string_free (group_sql, TRUE);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user