yangzhang75 commented on code in PR #8125:
URL: https://github.com/apache/texera/pull/8125#discussion_r3899688890


##########
sql/texera_ddl.sql:
##########
@@ -166,7 +166,10 @@ CREATE TABLE IF NOT EXISTS workflow
     content            TEXT NOT NULL,
     creation_time      TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
     last_modified_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
-    is_public          BOOLEAN NOT NULL DEFAULT false
+    is_public          BOOLEAN NOT NULL DEFAULT false,
+    -- Which view the workflow opens in by default (CANVAS or FORM); the 
form's definition
+    -- lives in workflow.content (`formBinding`).
+    default_view   VARCHAR NOT NULL DEFAULT 'CANVAS'

Review Comment:
   Done, though via a PG enum rather than a CHECK. The DDL now defines 
`default_view_enum AS ENUM ('CANVAS', 'FORM')` alongside the existing enum 
types, and the column is `default_view default_view_enum`, so a fresh database 
rejects any value outside the two at the DB level, including inserts through 
the create/persist DTO. It stays aligned with 44.sql, which creates the same 
type (with a duplicate_object guard) and uses it for the column.



##########
sql/updates/44.sql:
##########
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+\c texera_db
+
+SET search_path TO texera_db;
+
+BEGIN;
+
+-- Which view a workflow opens in by default (CANVAS or FORM). The form's 
definition lives
+-- in workflow.content under `formBinding`; only this preference is 
denormalized so listing
+-- endpoints need not parse every row's content. It never gates availability 
-- the form is
+-- reachable for every workflow.
+ALTER TABLE workflow
+    ADD COLUMN IF NOT EXISTS default_view VARCHAR NOT NULL DEFAULT 'CANVAS';

Review Comment:
   Enforced now via a PG enum instead of a CHECK: 44.sql creates 
`default_view_enum AS ENUM ('CANVAS', 'FORM')` (guarded with a duplicate_object 
block so it stays idempotent) and adds the column as that type, so 
`/workflow/create` and `/workflow/persist` can't bypass it. An out-of-range 
`defaultView` fails to deserialize into the generated `DefaultViewEnum` before 
it reaches `workflowDao.insert`, and the enum column rejects it regardless. 
Mirrored in texera_ddl.sql.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to