Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
147 commits
Select commit Hold shift + click to select a range
facbd36
feat(notebook): add types for notebook and cell structures
wibus-wee Sep 10, 2025
7393bd7
feat(notebook): enhance Cell and Notebook types with additional metad…
wibus-wee Sep 10, 2025
b0f04d4
refactor(notebook): restructure types by removing old definitions and…
wibus-wee Sep 10, 2025
d630780
feat(notebook): implement notebook state management with Jotai atoms …
wibus-wee Sep 11, 2025
f5d2d79
feat(web): add react-scan for development environment monitoring
wibus-wee Sep 11, 2025
0390ad4
feat(notebook): implement notebook editor and sidebar components
wibus-wee Sep 11, 2025
520f18a
feat(notebook): add optimized selector for notebook sidebar data
wibus-wee Sep 11, 2025
909d066
feat(notebook): enhance NotebookSidebar with improved layout and badg…
wibus-wee Sep 11, 2025
bf7c32f
fix(notebook): add cleanup logic to avoid memory leak
wibus-wee Sep 11, 2025
de70751
feat(notebook): implement database connection management in NotebookT…
wibus-wee Sep 12, 2025
2143c19
feat(web/notebook): introduced OutputRenderer to manage different out…
wibus-wee Sep 12, 2025
29aa015
feat(notebook): enhance cell execution logic with database connection…
wibus-wee Sep 12, 2025
3b27cfd
feat(notebook): enhance cell component with background DDL execution …
wibus-wee Sep 12, 2025
ccb6355
refactor(notebook): remove placeholder from MonacoEditor and Cell com…
wibus-wee Sep 12, 2025
77bbd37
feat(notebook): add preview mode for each cell block
wibus-wee Sep 12, 2025
d4d26e2
feat(monaco-editor): add auto-resize functionality with min and max h…
wibus-wee Sep 12, 2025
4794473
feat(notebook): add support for markdown cells and enhance cell type …
wibus-wee Sep 12, 2025
7947211
feat(notebook): implement cell addition logic with editor mode activa…
wibus-wee Sep 12, 2025
c770566
style: lint
wibus-wee Sep 12, 2025
6a6c5e8
feat(notebook): insert notebook cell in every place
wibus-wee Sep 12, 2025
c5303d4
refactor(notebook): restructure Cell component into modular subcompon…
wibus-wee Sep 12, 2025
a4aecfb
perf(monaco-editor): add loading placeholder to MonacoEditor component
wibus-wee Sep 12, 2025
6014253
feat(tailwind): add @tailwindcss/typography plugin and update styles
wibus-wee Sep 12, 2025
53e1394
feat(markdown): enhance MarkdownRenderer with Shiki syntax highlighting
wibus-wee Sep 13, 2025
0de6418
style(markdown): adjust Shiki text size in MarkdownRenderer
wibus-wee Sep 13, 2025
9a85532
perf(notebook): enhance NotebookSidebar with fixed width for better U…
wibus-wee Sep 13, 2025
cd869df
feat(notebook): implement resizable sidebar in NotebookSidebar for im…
wibus-wee Sep 13, 2025
349918f
fix(shiki): memory leak
wibus-wee Sep 13, 2025
d4a600f
feat(notebook): reset running cells in notebooks
wibus-wee Sep 13, 2025
9a746e9
refactor(notebook): remove reset logic for better design
wibus-wee Sep 13, 2025
9380789
refactor(notebook): remove cell status from metadata and implement ce…
wibus-wee Sep 13, 2025
e5dff02
feat(notebook): integrate run all cells functionality in NotebookToolbar
wibus-wee Sep 13, 2025
1d2d917
fix(web): disable shiki code highligher for better performance
wibus-wee Sep 13, 2025
0bf8023
feat(cell-editor): add optimized toggle action and selector for cell …
wibus-wee Sep 13, 2025
2414aef
refactor(notebook): remove unused UI state atom for cleaner code
wibus-wee Sep 13, 2025
a55a3d9
refactor: split code to different file
wibus-wee Sep 14, 2025
9cc17a6
refactor(notebook): isolate history tracking to individual notebooks
wibus-wee Sep 14, 2025
1e1f1f3
feat(notebook): add keyboard shortcuts for undo/redo functionality in…
wibus-wee Sep 14, 2025
4069334
refactor(notebook)!: enhance notebook history management and service …
wibus-wee Sep 14, 2025
8971d51
refactor(notebook): improve notebook history handling with dummy note…
wibus-wee Sep 14, 2025
8a0add7
fix(ErrorOutput): enhance error output styling for dark mode support
wibus-wee Sep 14, 2025
1475c44
feat(cell): add clear output functionality to cell component
wibus-wee Sep 14, 2025
ef6d7b7
fix(ShikiCodeBlock): enhance error handling and improve code readability
wibus-wee Sep 14, 2025
01cae11
feat(cell): add move cell functionality to Cell component
wibus-wee Sep 14, 2025
46a9253
feat(notebook): enhance NotebookToolbar with clear all outputs
wibus-wee Sep 14, 2025
81e59b0
feat(cell): add run cells above and below function
wibus-wee Sep 14, 2025
7c6f6d9
perf(notebook): set maxheight ot the table output
wibus-wee Sep 15, 2025
fea5e28
feat(notebook): introduce schema management and DDL detection
wibus-wee Sep 15, 2025
f3f05f6
feat(notebook): add LatestStreamingGraphTab component for real-time g…
wibus-wee Sep 15, 2025
ca1089c
feat(notebook): implement NotebookBottomPanel for enhanced UI state m…
wibus-wee Sep 15, 2025
4fa5bd0
feat(notebook): add @tanstack/react-virtual for improved performance …
wibus-wee Sep 15, 2025
1108cee
fix(notebook): adjust positioning of timeline dot in HistoryItem comp…
wibus-wee Sep 15, 2025
8cda516
refactor(notebook): streamline bottom panel state management in Noteb…
wibus-wee Sep 15, 2025
eb636ad
style(notebook): add dark mode support for streaming graph output com…
wibus-wee Sep 15, 2025
7c73384
feat(notebook): add confirmation dialog for clearing action history i…
wibus-wee Sep 15, 2025
3a14540
fix(notebook): handle schema fetching errors and return updated schem…
wibus-wee Sep 15, 2025
0eded43
feat(notebook): enhance HistoryItem component with AnimatePresence fo…
wibus-wee Sep 15, 2025
64d01f0
feat(notebook): add performance analysis and filtering for notebook h…
wibus-wee Sep 15, 2025
7d74f1f
Revert "feat(notebook): add performance analysis and filtering for no…
wibus-wee Sep 15, 2025
ca052e8
feat(sidebar): add Notebook menu item with NotebookPen icon
wibus-wee Sep 17, 2025
0ede58c
refactor(shiki): remove loading prop and improve code rendering
wibus-wee Sep 19, 2025
08702ed
feat(notebook): initialize Monaco editor loader on NotebookPage mount
wibus-wee Sep 19, 2025
1c5c76b
chore: remove useless helper function
wibus-wee Sep 19, 2025
11cd5b9
perf(notebook): improve panel resize handler ux
wibus-wee Sep 19, 2025
44b9bb0
style: code format
wibus-wee Sep 19, 2025
bf4d95b
feat(notebook): add multiple cells in notebooks
wibus-wee Sep 20, 2025
cac9110
feat(notebook): implement migration dialog and update cell addition l…
wibus-wee Sep 20, 2025
0c42bbc
feat(notebook): add export feature to notebook panel
wibus-wee Sep 20, 2025
f066ad1
style: lint
wibus-wee Sep 20, 2025
745e612
feat(notebook): implement notebook export feature
wibus-wee Sep 20, 2025
fae3bd4
feat(notebook): add notebook import functionality and enhance export …
wibus-wee Sep 20, 2025
1b2d23c
feat(notebook): add importer to sidebar, enhance importer and exporter
wibus-wee Sep 20, 2025
50169de
refactor(notebook): simplify bottom panel state and enhance UI respon…
wibus-wee Sep 20, 2025
01206b3
feat(notebook): support code preview collapse with spring animation
wibus-wee Sep 20, 2025
bacef83
feat(notebook): add uuid package and refactor ID generation for cells
wibus-wee Sep 20, 2025
182a28b
chore: remove last cell protect rule
wibus-wee Sep 20, 2025
bff45d6
fix(notebook): isLoading cause unnecessary cycles
wibus-wee Sep 20, 2025
ff11e76
fix(notebook): update metadata type to use `Partial<CellMetadata>` fo…
wibus-wee Sep 20, 2025
53540e9
refactor(notebook): all cell handling for improved performance
wibus-wee Sep 20, 2025
9f4111a
feat(notebook): integrate session history management for notebooks
wibus-wee Sep 21, 2025
1dfd4da
feat(notebook): implement future history feature
wibus-wee Sep 21, 2025
5f25e0b
refactor(notebook): clean up ActionHistoryTab and HistoryItem components
wibus-wee Sep 21, 2025
c6acc08
Merge branch 'main' into wibus/notebook-feat-1
wibus-wee Sep 23, 2025
eb5160b
refactor(wip): migrate jotai atom to yjs crdt
wibus-wee Sep 24, 2025
64845a0
Merge branch 'main' into wibus/notebook-feat-1
wibus-wee Sep 24, 2025
9913faf
chore(deps): install all deps
wibus-wee Sep 24, 2025
1540be4
refactor: optimize useCellModel for better snapshot management
wibus-wee Sep 24, 2025
3ecfd67
feat(web): implement JWT decoding and user context for collaboration …
wibus-wee Sep 24, 2025
a554289
chore: rename file
wibus-wee Sep 24, 2025
b76a74a
refactor(web): remove action history due to undo manager limit
wibus-wee Sep 24, 2025
b6be0d9
refactor(web): remove jotai atom layer
wibus-wee Sep 24, 2025
7c99b30
fix(notebook): ensure yjs is loaded in client side
wibus-wee Sep 24, 2025
21f7b5d
fix(notebook): resolve Yjs integration issues when moving cells by en…
wibus-wee Sep 24, 2025
8734442
feat: cursor support
wibus-wee Sep 24, 2025
23a5ce8
feat(yjs): introduce brand new yjs schema arch
wibus-wee Oct 16, 2025
2db3ee2
chore: remove old design
wibus-wee Oct 17, 2025
6e5f9b7
feat(notebook): add Yjs bindings and connection management for collab…
wibus-wee Oct 18, 2025
e7eec2f
refactor(notebook): migrate ui component with new design
wibus-wee Oct 18, 2025
76971b5
perf(notebook): fix useless re-render
wibus-wee Oct 19, 2025
ca0b2df
chore(deps): update anclax dependency and align transaction handling …
wibus-wee Oct 20, 2025
5c4fadf
feat(collab): introduce collaborative notebooks
wibus-wee Oct 26, 2025
7b04beb
refactor(notebook): isolate state management with Jotai providers
wibus-wee Oct 29, 2025
c5f5fe2
feat(collab): add ensureNotebookBootstrappedAtom for immediate notebo…
wibus-wee Oct 29, 2025
c8befc1
feat: multi update
wibus-wee Oct 31, 2025
2131004
feat: implement full-featured history feature
wibus-wee Nov 4, 2025
d73ad1b
feat: add Avatar component and PresenceAvatars for user presence indi…
wibus-wee Nov 4, 2025
40fcf1f
feat: add notebook presence management with connection handling and a…
wibus-wee Nov 4, 2025
38b91eb
refactor!(notebook): fully refactor notebook state management structure
wibus-wee Nov 6, 2025
5671fd1
test(schema): add test for yjs schema
wibus-wee Nov 6, 2025
3d1a577
1Merge branch 'main' into wibus/notebook-feat-1
wibus-wee Nov 6, 2025
1088e0b
merge
wibus-wee Nov 6, 2025
7a80dc2
update
wibus-wee Nov 6, 2025
c530c2f
feat(notebook): enhance cell state management with metadata support
wibus-wee Nov 7, 2025
8feaaa4
chore: update
wibus-wee Nov 7, 2025
80a10d3
perf(web): improve user experience with motion animation
wibus-wee Nov 13, 2025
e9fd9e9
feat(shiki): integrate Shiki highlighter with single instance and has…
wibus-wee Nov 19, 2025
d260585
fix(notebook): ensure notebook is ready on resource setup
wibus-wee Nov 19, 2025
63aad00
fix(services): send empty Yjs state update on new documents
wibus-wee Nov 19, 2025
452e36f
feat(notebook): add progress panel support
wibus-wee Nov 20, 2025
8573b57
refactor(notebook): rename functions for clarity and consistency
wibus-wee Nov 21, 2025
405f7d4
Merge branch 'main' into wibus/notebook-feat-1
wibus-wee Nov 22, 2025
5b38f6a
chore: recover jotai arch because too many errors
wibus-wee Nov 25, 2025
dd8a2fa
feat(notebook): implement debug panel and refactor notebook provider …
wibus-wee Nov 25, 2025
3dc0eb7
refactor(notebook): migrate awareness logic to Valtio
wibus-wee Nov 26, 2025
5a8e8ee
refactor(notebook): reverse the data flow to use route as source
wibus-wee Nov 27, 2025
2bf8101
refactor(notebook): consolidate notebook state management
wibus-wee Nov 27, 2025
d49d9ba
refactor(notebook): migrate to use pure tanstack query
wibus-wee Nov 28, 2025
42fb6a3
refactor(notebook): useCellState with valtio snapshot instead of cust…
wibus-wee Dec 1, 2025
51fdc8e
refactor(notebook): streamline notebook resource creation and remove …
wibus-wee Dec 9, 2025
621a528
refactor(notebook): use valtio as state management
wibus-wee Dec 9, 2025
aace8d2
fix(notebook): timing issues with network and initialization
wibus-wee Dec 9, 2025
90fa1b9
refactor(notebook): replace UserActionMonacoBinding with YjsMonacoBin…
wibus-wee Dec 9, 2025
44447fc
refactor(notebook): enhance snapshot uploading logic and improve sync…
wibus-wee Dec 10, 2025
f337d90
feat(notebook): use `y-indexeddb` as local persistence
wibus-wee Dec 10, 2025
e8cbdbd
feat(debug): implement DebugBus for monitoring
wibus-wee Dec 10, 2025
c8228c1
refactor: remove `y-indexeddb` for better dev env
wibus-wee Dec 11, 2025
68aa7d5
fix(service): send snapshot then send pending updates
wibus-wee Dec 11, 2025
531f251
feat(collaborative): enhance snapshot handling with Yjs state vector …
wibus-wee Dec 11, 2025
9b87f26
feat(service): refine pending update handling and improve snapshot pe…
wibus-wee Dec 11, 2025
146893b
feat(execution): add executedBy tracking and implement execution watc…
wibus-wee Dec 11, 2025
3470c4a
fix: eslint lint error
wibus-wee Dec 11, 2025
8b2e66e
feat: implement schema browser and sidebar tabs for notebook component
wibus-wee Dec 12, 2025
ad2d723
feat(notebook): implement coordinator election mechanism for maintena…
wibus-wee Dec 13, 2025
f04c984
refactor
wibus-wee Dec 13, 2025
2ae5d44
feat(notebook): add save status management and indicator component
wibus-wee Dec 13, 2025
828929f
feat(notebook): implement floating outline navigation for markdown he…
wibus-wee Dec 13, 2025
33457e0
fix(notebook/reconcile): add critical safety guard to prevent losting…
wibus-wee Dec 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
224 changes: 224 additions & 0 deletions api/v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,171 @@ paths:
schema:
$ref: "#/components/schemas/MetricMatrix"

/collab/notebooks:
get:
summary: List collaborative notebooks
description: Retrieve a list of collaborative notebooks
operationId: listCollabNotebooks
security:
- BearerAuth: []
responses:
"200":
description: Successfully retrieved collaborative notebook list
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/CollabNotebook"
post:
summary: Create a collaborative notebook
description: Create a new collaborative notebook
operationId: createCollabNotebook
security:
- BearerAuth: []
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/CollabNotebookCreateRequest"
responses:
"201":
description: Successfully created collaborative notebook
content:
application/json:
schema:
$ref: "#/components/schemas/CollabNotebook"

/collab/notebooks/{notebookID}:
get:
summary: Get collaborative notebook details
description: Retrieve details of a specific collaborative notebook
operationId: getCollabNotebook
security:
- BearerAuth: []
parameters:
- name: notebookID
in: path
required: true
schema:
type: string
responses:
"200":
description: Successfully retrieved collaborative notebook
content:
application/json:
schema:
$ref: "#/components/schemas/CollabNotebook"

put:
summary: Update a collaborative notebook
description: Update details of a specific collaborative notebook
operationId: updateCollabNotebook
security:
- BearerAuth: []
parameters:
- name: notebookID
in: path
required: true
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/CollabNotebook"
responses:
"200":
description: Successfully upd-ated collaborative notebook
content:
application/json:
schema:
$ref: "#/components/schemas/CollabNotebook"

delete:
summary: Delete a collaborative notebook
description: Permanently delete a collaborative notebook
operationId: deleteCollabNotebook
security:
- BearerAuth: []
parameters:
- name: notebookID
in: path
required: true
schema:
type: string
responses:
"204":
description: Notebook deleted successfully
"403":
description: Operation not permitted
"404":
description: Notebook not found
/collab/notebooks/{notebookID}/transfer:
post:
summary: Transfer collaborative notebook scope
description: Move a collaborative notebook between personal and organization scopes.
operationId: transferCollabNotebook
security:
- BearerAuth: []
parameters:
- name: notebookID
in: path
required: true
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/CollabNotebookTransferRequest"
responses:
"200":
description: Successfully transferred collaborative notebook
content:
application/json:
schema:
$ref: "#/components/schemas/CollabNotebook"
"400":
description: Invalid transfer request
"403":
description: Operation not permitted
"404":
description: Notebook not found

/collab/notebooks/{notebookID}/snapshot:
put:
summary: Upload a collaborative notebook snapshot
description: Persist the latest Yjs snapshot for a collaborative notebook.
operationId: uploadCollabNotebookSnapshot
security:
- BearerAuth: []
parameters:
- name: notebookID
in: path
required: true
schema:
type: string
description: Unique identifier of the collaborative notebook.
requestBody:
required: true
content:
application/octet-stream:
schema:
type: string
format: binary
examples:
snapshot:
summary: Encoded Yjs snapshot payload
value: ""
responses:
"204":
description: Snapshot stored successfully.


components:
securitySchemes:
BearerAuth:
Expand Down Expand Up @@ -1648,6 +1813,65 @@ components:
type: integer
format: int32

CollabNotebook:
type: object
required: [notebookID, title, createdAt, updatedAt]
properties:
notebookID:
type: string
description: Unique identifier of the collaborative notebook
title:
type: string
description: Title of the collaborative notebook
scope:
type: string
enum: [personal, organization]
description: Ownership scope of the notebook
organizationID:
type: integer
format: int32
description: Organization that currently owns the notebook
ownerUserID:
type: integer
format: int32
description: User that owns the notebook when scope is personal
createdByUserID:
type: integer
format: int32
description: User that originally created the notebook
createdAt:
type: string
format: date-time
description: Creation timestamp
updatedAt:
type: string
format: date-time
description: Last update timestamp

CollabNotebookCreateRequest:
type: object
required: [title]
properties:
title:
type: string
description: Title of the collaborative notebook
scope:
type: string
enum: [personal, organization]
description: Ownership scope of the notebook; defaults to personal when omitted

CollabNotebookTransferRequest:
type: object
required: [targetScope]
properties:
targetScope:
type: string
enum: [personal, organization]
description: Desired ownership scope
ownerUserID:
type: integer
format: int32
description: Target owner when moving to personal scope; defaults to the caller
PromdumpOpt:
type: object
required: [endpoint, start, end, step, query, gzip, parts, memoryRatio]
Expand Down
5 changes: 4 additions & 1 deletion dev/anclax.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ externals:
wire: v0.6.0
sqlc: v1.29.0
mockgen: v0.5.0
anclax: v0.6.6
# Align with go.mod: dev-v0.7 resolves to v0.6.16 pseudo-version
anclax: dev-v0.7

oapi-codegen:
path: api/v1.yaml
Expand Down Expand Up @@ -46,3 +47,5 @@ mockgen:
- source: pkg/conn/http/http.go
destination: pkg/conn/http/mock/http_mock_gen.go
package: mock

anclaxdef: dev/anclax
7 changes: 7 additions & 0 deletions dev/anclax/sql/migrations/0001_init.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
BEGIN;

DROP TABLE IF EXISTS anclax.users;
DROP TABLE IF EXISTS anclax.keys;
DROP TABLE IF EXISTS anclax.opaque_tokens;

COMMIT;
120 changes: 120 additions & 0 deletions dev/anclax/sql/migrations/0001_init.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
BEGIN;

CREATE SCHEMA IF NOT EXISTS anclax;

CREATE TABLE IF NOT EXISTS anclax.orgs (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
tz TEXT NOT NULL DEFAULT 'Asia/Shanghai',
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP NOT NULL
);

CREATE TABLE IF NOT EXISTS anclax.users (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
password_hash TEXT NOT NULL,
password_salt TEXT NOT NULL,
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP NOT NULL,
deleted_at TIMESTAMPTZ
);

CREATE TABLE IF NOT EXISTS anclax.user_default_orgs (
user_id INTEGER NOT NULL REFERENCES anclax.users(id) ON UPDATE CASCADE ON DELETE CASCADE,
org_id INTEGER NOT NULL REFERENCES anclax.orgs(id) ON UPDATE CASCADE ON DELETE CASCADE,
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP NOT NULL,

PRIMARY KEY (user_id)
);

CREATE TABLE IF NOT EXISTS anclax.org_users (
org_id INTEGER NOT NULL REFERENCES anclax.orgs(id) ON UPDATE CASCADE ON DELETE CASCADE,
user_id INTEGER NOT NULL REFERENCES anclax.users(id) ON UPDATE CASCADE ON DELETE CASCADE,
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP NOT NULL,

PRIMARY KEY (org_id, user_id)
);

CREATE TABLE IF NOT EXISTS anclax.org_owners (
org_id INTEGER NOT NULL REFERENCES anclax.orgs(id) ON UPDATE CASCADE ON DELETE CASCADE,
user_id INTEGER NOT NULL REFERENCES anclax.users(id) ON UPDATE CASCADE,
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP NOT NULL,

PRIMARY KEY (org_id)
);

CREATE TABLE IF NOT EXISTS anclax.opaque_keys (
id BIGSERIAL PRIMARY KEY,
key BYTEA NOT NULL,
user_id INT NOT NULL REFERENCES anclax.users(id) ON DELETE CASCADE ON UPDATE CASCADE,
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP NOT NULL
);

CREATE TABLE IF NOT EXISTS anclax.access_key_pairs (
access_key VARCHAR(20) NOT NULL,
secret_key VARCHAR(40) NOT NULL,
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP NOT NULL,

PRIMARY KEY (access_key)
);

CREATE TABLE IF NOT EXISTS anclax.access_rules (
name VARCHAR(255) NOT NULL,
description TEXT NOT NULL,
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP NOT NULL,

PRIMARY KEY (name)
);

CREATE TABLE IF NOT EXISTS anclax.roles (
id SERIAL PRIMARY KEY,
org_id INTEGER NOT NULL REFERENCES anclax.orgs(id) ON UPDATE CASCADE,
name VARCHAR(255) NOT NULL,
description TEXT NOT NULL,
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP NOT NULL
);

CREATE TABLE IF NOT EXISTS anclax.role_access_rules (
role_id INTEGER NOT NULL,
access_rule_name VARCHAR(255) NOT NULL REFERENCES anclax.access_rules(name) ON UPDATE CASCADE,
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP NOT NULL,

PRIMARY KEY (role_id, access_rule_name)
);

CREATE TABLE IF NOT EXISTS anclax.users_roles (
user_id INTEGER NOT NULL,
role_id INTEGER NOT NULL,
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP NOT NULL,

PRIMARY KEY (user_id, role_id)
);

CREATE TABLE IF NOT EXISTS anclax.tasks (
id SERIAL PRIMARY KEY,
attributes JSONB NOT NULL,
spec JSONB NOT NULL,
status VARCHAR(255) NOT NULL,
unique_tag VARCHAR(255), -- for unique task
started_at TIMESTAMPTZ,
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,

UNIQUE (unique_tag)
);

CREATE TABLE IF NOT EXISTS anclax.events (
id SERIAL PRIMARY KEY,
spec JSONB NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
);

COMMIT;
6 changes: 6 additions & 0 deletions dev/anclax/sql/migrations/0002_retry_count.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
BEGIN;

ALTER TABLE anclax.tasks DROP COLUMN attempts;

COMMIT;

7 changes: 7 additions & 0 deletions dev/anclax/sql/migrations/0002_retry_count.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
BEGIN;

ALTER TABLE anclax.tasks ADD COLUMN attempts INTEGER NOT NULL DEFAULT 0;

UPDATE anclax.tasks SET attributes = jsonb_set(attributes, '{retryPolicy, maxAttempts}', '-1') WHERE (attributes->'retryPolicy'->'always_retry_on_failure')::BOOLEAN;

COMMIT;
Loading