Skip to content

Commit

Permalink
Add last_status_number to backend table (#756)
Browse files Browse the repository at this point in the history
This adds a (nullable) `last_status_number` column to backend. A
follow-up PR will populate this column.

Per [postgres
docs](https://www.postgresql.org/docs/current/sql-altertable.html#SQL-ALTERTABLE-NOTES):

> When a column is added with ADD COLUMN and a non-volatile DEFAULT is
specified, the default is evaluated at the time of the statement and the
result stored in the table's metadata. That value will be used for the
column for all existing rows. If no DEFAULT is specified, NULL is used.
In neither case is a rewrite of the table required.

So this is a cheap migration.
  • Loading branch information
paulgb authored Jun 25, 2024
1 parent 682bbe4 commit 630e120
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 9 additions & 1 deletion plane/schema/derived_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ CREATE TABLE public.backend (
allowed_idle_seconds integer,
state jsonb NOT NULL,
static_token character varying(256),
subdomain character varying(255)
subdomain character varying(255),
last_status_number integer
);


Expand Down Expand Up @@ -190,6 +191,13 @@ COMMENT ON COLUMN public.backend.state IS 'The most recent state of the backend.
COMMENT ON COLUMN public.backend.subdomain IS 'Optional subdomain for session backend';


--
-- Name: COLUMN backend.last_status_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.backend.last_status_number IS 'Number representation of last_status, used for ordering.';


--
-- Name: backend_action; Type: TABLE; Schema: public; Owner: postgres
--
Expand Down
3 changes: 3 additions & 0 deletions plane/schema/migrations/20240625170232_add-status-number.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
alter table backend add column last_status_number integer;

comment on column backend.last_status_number is 'Number representation of last_status, used for ordering.';

0 comments on commit 630e120

Please sign in to comment.