mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-01-31 08:25:38 +00:00
Get rid of false foreign key in Relay.
This commit is contained in:
parent
8c18c60c00
commit
1ffd67e014
@ -184,9 +184,9 @@ SqliteNetworkController::SqliteNetworkController(const char *dbPath) :
|
||||
||(sqlite3_prepare_v2(_db,"DELETE FROM IpAssignment WHERE networkId = ? AND nodeId IS NULL AND \"type\" = ?",-1,&_sDeleteLocalRoutes,(const char **)0) != SQLITE_OK)
|
||||
|
||||
/* Relay */
|
||||
||(sqlite3_prepare_v2(_db,"SELECT nodeId,phyAddress FROM Relay WHERE networkId = ? ORDER BY nodeId ASC",-1,&_sGetRelays,(const char **)0) != SQLITE_OK)
|
||||
||(sqlite3_prepare_v2(_db,"SELECT \"address\",\"phyAddress\" FROM Relay WHERE \"networkId\" = ? ORDER BY \"address\" ASC",-1,&_sGetRelays,(const char **)0) != SQLITE_OK)
|
||||
||(sqlite3_prepare_v2(_db,"DELETE FROM Relay WHERE networkId = ?",-1,&_sDeleteRelaysForNetwork,(const char **)0) != SQLITE_OK)
|
||||
||(sqlite3_prepare_v2(_db,"INSERT INTO Relay (networkId,nodeId,phyAddress) VALUES (?,?,?)",-1,&_sCreateRelay,(const char **)0) != SQLITE_OK)
|
||||
||(sqlite3_prepare_v2(_db,"INSERT INTO Relay (\"networkId\",\"address\",\"phyAddress\") VALUES (?,?,?)",-1,&_sCreateRelay,(const char **)0) != SQLITE_OK)
|
||||
|
||||
/* Member */
|
||||
||(sqlite3_prepare_v2(_db,"SELECT rowid,authorized,activeBridge FROM Member WHERE networkId = ? AND nodeId = ?",-1,&_sGetMember,(const char **)0) != SQLITE_OK)
|
||||
@ -205,7 +205,7 @@ SqliteNetworkController::SqliteNetworkController(const char *dbPath) :
|
||||
|
||||
/* Config */
|
||||
||(sqlite3_prepare_v2(_db,"SELECT \"v\" FROM \"Config\" WHERE \"k\" = ?",-1,&_sGetConfig,(const char **)0) != SQLITE_OK)
|
||||
||(sqlite3_prepare_v2(_db,"INSERT OR REPLACE INTO \"Config\" (\"k\",\"v\") VALUES (?,?)",-1,&_sSetConfig,(const char **)0) != SQLITE_OK)
|
||||
||(sqlite3_prepare_v2(_db,"INSERT INTO \"Config\" (\"k\",\"v\") VALUES (?,?)",-1,&_sSetConfig,(const char **)0) != SQLITE_OK)
|
||||
|
||||
) {
|
||||
//printf("!!! %s\n",sqlite3_errmsg(_db));
|
||||
@ -227,7 +227,7 @@ SqliteNetworkController::SqliteNetworkController(const char *dbPath) :
|
||||
sqlite3_reset(_sSetConfig);
|
||||
sqlite3_bind_text(_sSetConfig,1,"instanceId",10,SQLITE_STATIC);
|
||||
sqlite3_bind_text(_sSetConfig,2,instanceId,32,SQLITE_STATIC);
|
||||
if (sqlite3_step(_sSetConfig) != SQLITE_OK) {
|
||||
if (sqlite3_step(_sSetConfig) != SQLITE_DONE) {
|
||||
sqlite3_close(_db);
|
||||
throw std::runtime_error("SqliteNetworkController unable to read or initialize instanceId");
|
||||
}
|
||||
|
@ -67,12 +67,11 @@ CREATE INDEX Member_networkId_memberRevision ON Member(networkId, memberRevision
|
||||
|
||||
CREATE TABLE Relay (
|
||||
networkId char(16) NOT NULL REFERENCES Network(id) ON DELETE CASCADE,
|
||||
nodeId char(10) NOT NULL REFERENCES Node(id) ON DELETE CASCADE,
|
||||
phyAddress varchar(64) NOT NULL,
|
||||
PRIMARY KEY (networkId, nodeId)
|
||||
address char(10) NOT NULL,
|
||||
phyAddress varchar(64) NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX Relay_networkId ON Relay (networkId);
|
||||
CREATE UNIQUE INDEX Relay_networkId_address ON Relay (networkId,address);
|
||||
|
||||
CREATE TABLE Rule (
|
||||
networkId char(16) NOT NULL REFERENCES Network(id) ON DELETE CASCADE,
|
||||
|
@ -68,12 +68,11 @@
|
||||
"\n"\
|
||||
"CREATE TABLE Relay (\n"\
|
||||
" networkId char(16) NOT NULL REFERENCES Network(id) ON DELETE CASCADE,\n"\
|
||||
" nodeId char(10) NOT NULL REFERENCES Node(id) ON DELETE CASCADE,\n"\
|
||||
" phyAddress varchar(64) NOT NULL,\n"\
|
||||
" PRIMARY KEY (networkId, nodeId)\n"\
|
||||
" address char(10) NOT NULL,\n"\
|
||||
" phyAddress varchar(64) NOT NULL\n"\
|
||||
");\n"\
|
||||
"\n"\
|
||||
"CREATE INDEX Relay_networkId ON Relay (networkId);\n"\
|
||||
"CREATE UNIQUE INDEX Relay_networkId_address ON Relay (networkId,address);\n"\
|
||||
"\n"\
|
||||
"CREATE TABLE Rule (\n"\
|
||||
" networkId char(16) NOT NULL REFERENCES Network(id) ON DELETE CASCADE,\n"\
|
||||
|
Loading…
x
Reference in New Issue
Block a user