db: Reorder migrations to reflect their relationship

This is dangerous but needed since postgres is not as forgiving about
unsatisfied foreign key constraints even while in a DB transaction.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
Christian Decker 2019-09-05 16:07:12 +02:00 committed by Rusty Russell
parent e2f7c86271
commit 3df8ccd3e0

View File

@ -55,6 +55,13 @@ static struct migration dbmigrations[] = {
", PRIMARY KEY (shachain_id, pos)"
");"),
NULL},
{SQL("CREATE TABLE peers ("
" id INTEGER"
", node_id BLOB UNIQUE" /* pubkey */
", address TEXT"
", PRIMARY KEY (id)"
");"),
NULL},
{SQL("CREATE TABLE channels ("
" id INTEGER," /* chan->id */
" peer_id INTEGER REFERENCES peers(id) ON DELETE CASCADE,"
@ -97,13 +104,6 @@ static struct migration dbmigrations[] = {
" PRIMARY KEY (id)"
");"),
NULL},
{SQL("CREATE TABLE peers ("
" id INTEGER"
", node_id BLOB UNIQUE" /* pubkey */
", address TEXT"
", PRIMARY KEY (id)"
");"),
NULL},
{SQL("CREATE TABLE channel_configs ("
" id INTEGER,"
" dust_limit_satoshis INTEGER,"