flagon-io/g1t

public

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

g1t/services/identity/migrations/0001_init.sql

42 lines1,212 bytesCodeBlame

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

Initial g1t: services, event bus, intents and attempts1CREATE TABLE users (
2 id INTEGER PRIMARY KEY,
3 username TEXT NOT NULL UNIQUE,
4 email TEXT,
5 password_hash TEXT NOT NULL,
6 created_at INTEGER NOT NULL DEFAULT (unixepoch())
7);
8
9-- id is the SHA-256 of the session cookie value.
10CREATE TABLE sessions (
11 id TEXT PRIMARY KEY,
12 user_id INTEGER NOT NULL REFERENCES users (id) ON DELETE CASCADE,
13 expires_at INTEGER NOT NULL
14);
15
16CREATE TABLE access_tokens (
17 id INTEGER PRIMARY KEY,
18 user_id INTEGER NOT NULL REFERENCES users (id) ON DELETE CASCADE,
19 name TEXT NOT NULL,
20 token_hash TEXT NOT NULL UNIQUE,
21 created_at INTEGER NOT NULL DEFAULT (unixepoch())
22);
23
24CREATE TABLE ssh_keys (
25 id INTEGER PRIMARY KEY,
26 user_id INTEGER NOT NULL REFERENCES users (id) ON DELETE CASCADE,
27 title TEXT NOT NULL,
28 public_key TEXT NOT NULL,
29 fingerprint TEXT NOT NULL UNIQUE,
30 created_at INTEGER NOT NULL DEFAULT (unixepoch())
31);
32
33-- Stored in Artifacts as "<owner username>--<name>".
34CREATE TABLE repos (
35 id INTEGER PRIMARY KEY,
36 owner_id INTEGER NOT NULL REFERENCES users (id) ON DELETE CASCADE,
37 name TEXT NOT NULL,
38 description TEXT,
39 is_private INTEGER NOT NULL DEFAULT 0,
40 created_at INTEGER NOT NULL DEFAULT (unixepoch()),
41 UNIQUE (owner_id, name)
42);