diff --git a/dbschema/default.esdl b/dbschema/default.esdl index d119b3c..7d70c52 100644 --- a/dbschema/default.esdl +++ b/dbschema/default.esdl @@ -8,17 +8,10 @@ module default { )) ); - required global currentConversationID: uuid { - default := "00000000-0000-0000-0000-000000000000" - }; - - global currentConversation := ( + global currentConversation := ( assert_single(( select Conversation - filter .user = global currentUser AND ( - .id = global currentConversationID OR - (global currentConversationID = "00000000-0000-0000-0000-000000000000" AND .name = 'Default') - ) + filter .user = global currentUser AND .selected = true )) ); @@ -52,6 +45,9 @@ module default { type Conversation { required name: str; required position: int32; + required selected: bool { + default := false; + }; required user: User { on target delete delete source; }; diff --git a/dbschema/migrations/00048-m1xxfsh.edgeql b/dbschema/migrations/00048-m1xxfsh.edgeql new file mode 100644 index 0000000..81f9da8 --- /dev/null +++ b/dbschema/migrations/00048-m1xxfsh.edgeql @@ -0,0 +1,9 @@ +CREATE MIGRATION m1xxfshhhqeharx244nyz5gs27xxrsp6bhb2f7smizwj6pf3bsqwtq + ONTO m1nb4byflyh4jp3yp6zdr6ydzw7btucfslsznwz7ooywnmbjxqyl6q +{ + ALTER TYPE default::Conversation { + CREATE REQUIRED PROPERTY seleted: std::bool { + SET default := false; + }; + }; +}; diff --git a/dbschema/migrations/00049-m1rtddn.edgeql b/dbschema/migrations/00049-m1rtddn.edgeql new file mode 100644 index 0000000..d2900b9 --- /dev/null +++ b/dbschema/migrations/00049-m1rtddn.edgeql @@ -0,0 +1,6 @@ +CREATE MIGRATION m1rtddnmmb2imreqjy622lkxgmzrtau77xggdw477im46cgn53njza + ONTO m1xxfshhhqeharx244nyz5gs27xxrsp6bhb2f7smizwj6pf3bsqwtq +{ + DROP GLOBAL default::currentConversation; + DROP GLOBAL default::currentConversationID; +}; diff --git a/dbschema/migrations/00050-m1kkf4h.edgeql b/dbschema/migrations/00050-m1kkf4h.edgeql new file mode 100644 index 0000000..cab0794 --- /dev/null +++ b/dbschema/migrations/00050-m1kkf4h.edgeql @@ -0,0 +1,14 @@ +CREATE MIGRATION m1kkf4hwv2zxvzjxckc4semtent43nd4ed4bn5462ph2ffpocpo24a + ONTO m1rtddnmmb2imreqjy622lkxgmzrtau77xggdw477im46cgn53njza +{ + ALTER TYPE default::Conversation { + ALTER PROPERTY seleted { + RENAME TO selected; + }; + }; + CREATE GLOBAL default::currentConversation := (std::assert_single((SELECT + default::Conversation + FILTER + ((.user = GLOBAL default::currentUser) AND (.selected = true)) + ))); +};