diff --git a/db/define.go b/db/define.go index 8bb74eac..197fa59a 100644 --- a/db/define.go +++ b/db/define.go @@ -37,6 +37,12 @@ func executeDefineTableStatement(txn kvs.TX, ast *sql.DefineTableStatement) (out for _, TB := range ast.What { + // Set the namespace definition + nkey := &keys.NS{KV: ast.KV, NS: ast.NS} + if err := txn.Put(nkey.Encode(), nil); err != nil { + return nil, err + } + // Set the database definition dkey := &keys.DB{KV: ast.KV, NS: ast.NS, DB: ast.DB} if err := txn.Put(dkey.Encode(), nil); err != nil { @@ -76,6 +82,12 @@ func executeDefineRulesStatement(txn kvs.TX, ast *sql.DefineRulesStatement) (out for _, RU := range ast.When { + // Set the namespace definition + nkey := &keys.NS{KV: ast.KV, NS: ast.NS} + if err := txn.Put(nkey.Encode(), nil); err != nil { + return nil, err + } + // Set the database definition dkey := &keys.DB{KV: ast.KV, NS: ast.NS, DB: ast.DB} if err := txn.Put(dkey.Encode(), nil); err != nil { @@ -121,6 +133,12 @@ func executeDefineFieldStatement(txn kvs.TX, ast *sql.DefineFieldStatement) (out for _, TB := range ast.What { + // Set the namespace definition + nkey := &keys.NS{KV: ast.KV, NS: ast.NS} + if err := txn.Put(nkey.Encode(), nil); err != nil { + return nil, err + } + // Set the database definition dkey := &keys.DB{KV: ast.KV, NS: ast.NS, DB: ast.DB} if err := txn.Put(dkey.Encode(), nil); err != nil { @@ -164,6 +182,12 @@ func executeDefineIndexStatement(txn kvs.TX, ast *sql.DefineIndexStatement) (out for _, TB := range ast.What { + // Set the namespace definition + nkey := &keys.NS{KV: ast.KV, NS: ast.NS} + if err := txn.Put(nkey.Encode(), nil); err != nil { + return nil, err + } + // Set the database definition dkey := &keys.DB{KV: ast.KV, NS: ast.NS, DB: ast.DB} if err := txn.Put(dkey.Encode(), nil); err != nil {