mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-28 22:25:24 +00:00
48 lines
2.1 KiB
SQL
48 lines
2.1 KiB
SQL
-- termix-identity 0001: adopt_termix_identity_tables
|
|
-- Generated by termix-plugin migrations. Review before committing.
|
|
-- Hand-edited: keeps the legacy foreign keys the SDK cannot declare
|
|
-- (keys and ca to their identity, keys to ssh_credentials).
|
|
|
|
CREATE TABLE IF NOT EXISTS "termix_identities" (
|
|
"id" serial PRIMARY KEY,
|
|
"user_id" varchar(255) NOT NULL UNIQUE,
|
|
"handle" varchar(255) NOT NULL UNIQUE,
|
|
"description" text,
|
|
"created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"updated_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE
|
|
);
|
|
ALTER TABLE "termix_identities" RENAME TO "p_termix_identity_identities";
|
|
CREATE TABLE IF NOT EXISTS "termix_identity_keys" (
|
|
"id" serial PRIMARY KEY,
|
|
"identity_id" integer NOT NULL,
|
|
"user_id" varchar(255) NOT NULL,
|
|
"public_key" text NOT NULL,
|
|
"key_type" text NOT NULL,
|
|
"algorithm" text NOT NULL,
|
|
"label" text,
|
|
"comment" text,
|
|
"source" text NOT NULL DEFAULT 'manual',
|
|
"credential_id" integer,
|
|
"enabled" boolean NOT NULL DEFAULT true,
|
|
"created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE,
|
|
FOREIGN KEY ("identity_id") REFERENCES "p_termix_identity_identities" ("id") ON DELETE CASCADE,
|
|
FOREIGN KEY ("credential_id") REFERENCES "ssh_credentials" ("id") ON DELETE SET NULL
|
|
);
|
|
CREATE INDEX IF NOT EXISTS "idx_termix_identity_keys_identity" ON "termix_identity_keys" ("identity_id");
|
|
ALTER TABLE "termix_identity_keys" RENAME TO "p_termix_identity_keys";
|
|
CREATE TABLE IF NOT EXISTS "termix_identity_ca" (
|
|
"id" serial PRIMARY KEY,
|
|
"identity_id" integer NOT NULL UNIQUE,
|
|
"user_id" varchar(255) NOT NULL,
|
|
"public_key" text NOT NULL,
|
|
"private_key" text NOT NULL,
|
|
"validity_days" integer NOT NULL DEFAULT 90,
|
|
"created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"updated_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE,
|
|
FOREIGN KEY ("identity_id") REFERENCES "p_termix_identity_identities" ("id") ON DELETE CASCADE
|
|
);
|
|
ALTER TABLE "termix_identity_ca" RENAME TO "p_termix_identity_ca";
|