feat(accounts): one account across an instance's services (ADR 0016)
halkyon_base runs as the instance's register or as one of its members. The register keeps the ways in, handles and profiles; members ask it over HTTP with the instance's shared secret (instanceSecret), and open sessions of their own for its accounts, under the same account ID. - AccountsMode from the environment: INSTANCE_MEMBERS on the register, ACCOUNT_REGISTER_URL on a member. Learn always holds the register (Explore joins the profiles); Todo is a member where it is set. - AccountRegister: LocalRegister, RemoteRegister, an in-memory one in tests. Calls between services on the web server, refused without the secret (constant-time compare); a server needing it doesn't start without it. - Deleting an account deletes it everywhere: notices per member kept in the deletion's transaction (account_deletion_notice), told at once and hourly until confirmed; members prune daily whom the register no longer knows, never while it knows none of them or can't be reached. - Deploy: INSTANCE_SECRET and INSTANCE_MEMBERS in compose and .env. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
4107cc3087
commit
65c5cd740d
13 changed files with 41906 additions and 167 deletions
|
|
@ -9,8 +9,12 @@ Future<void> run(List<String> args) async {
|
|||
// The generated Serverpod is already connected with the generated code.
|
||||
final pod = Serverpod(args);
|
||||
// What every Halkyon server has (ADR 0014): sign-in, the account and its
|
||||
// deletion, the pruning, the instance's basics, set up for Todo.
|
||||
HalkyonBase.configure(pod, todoBase());
|
||||
// deletion, the pruning, the instance's basics, set up for Todo; a member
|
||||
// of the instance's register where the operator names one (ADR 0016).
|
||||
HalkyonBase.configure(
|
||||
pod,
|
||||
todoBase(accounts: AccountsMode.fromEnvironment()),
|
||||
);
|
||||
// Token managers validate and issue authentication keys; identity
|
||||
// providers are the ways people can sign in (halkyon_base's
|
||||
// auth_config.dart).
|
||||
|
|
@ -19,6 +23,10 @@ Future<void> run(List<String> args) async {
|
|||
identityProviderBuilders: identityProviderBuilders(pod),
|
||||
);
|
||||
|
||||
// The calls between the instance's services, on the web server
|
||||
// (ADR 0016); Caddy never forwards them.
|
||||
addInstanceRoutes(pod);
|
||||
|
||||
await pod.start();
|
||||
|
||||
await schedulePruning(pod);
|
||||
|
|
|
|||
|
|
@ -62,6 +62,10 @@ class FutureCalls extends _is.FutureCallDispatch<_FutureCallRef> {
|
|||
PruningPruneAnonymousPeopleFutureCall(),
|
||||
'PruningForgetSignUpAttemptsFutureCall':
|
||||
PruningForgetSignUpAttemptsFutureCall(),
|
||||
'PruningTellMembersOfDeletionsFutureCall':
|
||||
PruningTellMembersOfDeletionsFutureCall(),
|
||||
'PruningForgetDeletedAccountsFutureCall':
|
||||
PruningForgetDeletedAccountsFutureCall(),
|
||||
};
|
||||
_futureCallManager = futureCallManager;
|
||||
_serverId = serverId;
|
||||
|
|
@ -203,6 +207,20 @@ class _PruningFutureCallDispatcher {
|
|||
null,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> tellMembersOfDeletions() {
|
||||
return _invokeFutureCall(
|
||||
'PruningTellMembersOfDeletionsFutureCall',
|
||||
null,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> forgetDeletedAccounts() {
|
||||
return _invokeFutureCall(
|
||||
'PruningForgetDeletedAccountsFutureCall',
|
||||
null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Prunes one batch and logs how many people went.
|
||||
|
|
@ -230,3 +248,29 @@ class PruningForgetSignUpAttemptsFutureCall extends _is.FutureCall
|
|||
await _ibrplims.PruningFutureCall().forgetSignUpAttempts(session);
|
||||
}
|
||||
}
|
||||
|
||||
/// On the register, tells the instance's members again of the accounts
|
||||
/// gone that they haven't confirmed yet, and logs how many confirmed.
|
||||
class PruningTellMembersOfDeletionsFutureCall extends _is.FutureCall
|
||||
implements _is.InvokableFutureCall {
|
||||
@override
|
||||
_ida.Future<void> invoke(
|
||||
_is.Session session,
|
||||
_is.SerializableModel? object,
|
||||
) async {
|
||||
await _ibrplims.PruningFutureCall().tellMembersOfDeletions(session);
|
||||
}
|
||||
}
|
||||
|
||||
/// On a member, deletes the people whose account the register no longer
|
||||
/// knows, and logs how many.
|
||||
class PruningForgetDeletedAccountsFutureCall extends _is.FutureCall
|
||||
implements _is.InvokableFutureCall {
|
||||
@override
|
||||
_ida.Future<void> invoke(
|
||||
_is.Session session,
|
||||
_is.SerializableModel? object,
|
||||
) async {
|
||||
await _ibrplims.PruningFutureCall().forgetDeletedAccounts(session);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,13 +7,27 @@ const _pruning = 'prune-abandoned-anonymous-people';
|
|||
/// The identifier of the hourly forgetting of sign-up attempts.
|
||||
const _attemptPruning = 'forget-sign-up-attempts';
|
||||
|
||||
/// The identifier of the hourly telling of the members of deleted accounts.
|
||||
const _deletionNotices = 'tell-members-of-deletions';
|
||||
|
||||
/// The identifier of the daily deleting of accounts the register forgot.
|
||||
const _deletedAccounts = 'forget-deleted-accounts';
|
||||
|
||||
/// The future calls [schedulePruning] keeps scheduled, by their identifiers.
|
||||
const pruningIdentifiers = [_pruning, _attemptPruning];
|
||||
const pruningIdentifiers = [
|
||||
_pruning,
|
||||
_attemptPruning,
|
||||
_deletionNotices,
|
||||
_deletedAccounts,
|
||||
];
|
||||
|
||||
/// Schedules the pruning (`PruningFutureCall`): abandoned anonymous people
|
||||
/// daily, sign-up attempts and expired email codes hourly. Scheduling always
|
||||
/// adds an entry, so the previous one goes first, and starting the server
|
||||
/// again leaves one of each.
|
||||
/// daily, sign-up attempts and expired email codes hourly, and the instance's
|
||||
/// accounts (ADR 0016): the register's deletions its members haven't
|
||||
/// confirmed hourly, a member's people the register forgot daily (each does
|
||||
/// nothing in the other mode). Scheduling always adds an entry, so the
|
||||
/// previous one goes first, and starting the server again leaves one of
|
||||
/// each.
|
||||
Future<void> schedulePruning(Serverpod pod) async {
|
||||
await pod.futureCalls.cancel(_pruning);
|
||||
await pod.futureCalls
|
||||
|
|
@ -28,4 +42,18 @@ Future<void> schedulePruning(Serverpod pod) async {
|
|||
.cron('27 * * * *')
|
||||
.pruning
|
||||
.forgetSignUpAttempts();
|
||||
|
||||
await pod.futureCalls.cancel(_deletionNotices);
|
||||
await pod.futureCalls
|
||||
.callRecurring(identifier: _deletionNotices)
|
||||
.cron('52 * * * *')
|
||||
.pruning
|
||||
.tellMembersOfDeletions();
|
||||
|
||||
await pod.futureCalls.cancel(_deletedAccounts);
|
||||
await pod.futureCalls
|
||||
.callRecurring(identifier: _deletedAccounts)
|
||||
.cron('37 3 * * *')
|
||||
.pruning
|
||||
.forgetDeletedAccounts();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,10 @@ import 'package:serverpod/serverpod.dart';
|
|||
/// Deletes the anonymous people nobody can return to, daily, and the IP
|
||||
/// addresses of sign-up attempts the rate limit is done with and the email
|
||||
/// sign-in codes past their time, hourly: halkyon_base's pruning (ADR 0014),
|
||||
/// which the server schedules when it starts (`schedulePruning`).
|
||||
/// which the server schedules when it starts (`schedulePruning`). Then the
|
||||
/// instance's accounts (ADR 0016): as its register, telling the members
|
||||
/// again of the accounts gone, hourly; as a member, deleting the people
|
||||
/// whose account the register no longer knows, daily.
|
||||
class PruningFutureCall extends FutureCall {
|
||||
/// Prunes one batch and logs how many people went.
|
||||
Future<void> pruneAnonymousPeople(Session session) async {
|
||||
|
|
@ -25,4 +28,18 @@ class PruningFutureCall extends FutureCall {
|
|||
final codes = await forgetExpiredEmailCodes(session, now: now);
|
||||
session.log('Forgot $forgotten sign-up attempts and $codes email codes.');
|
||||
}
|
||||
|
||||
/// On the register, tells the instance's members again of the accounts
|
||||
/// gone that they haven't confirmed yet, and logs how many confirmed.
|
||||
Future<void> tellMembersOfDeletions(Session session) async {
|
||||
final confirmed = await deliverDeletionNotices(session);
|
||||
session.log('Members confirmed $confirmed deleted accounts.');
|
||||
}
|
||||
|
||||
/// On a member, deletes the people whose account the register no longer
|
||||
/// knows, and logs how many.
|
||||
Future<void> forgetDeletedAccounts(Session session) async {
|
||||
final forgotten = await forgetPeopleTheRegisterForgot(session);
|
||||
session.log('Deleted $forgotten people the register no longer knows.');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,11 +17,16 @@ const minimumAppBuild = 1;
|
|||
/// the instance's basics: the instance says it serves `todo` (the app accepts
|
||||
/// only such an instance; never change it), sign-in mails name the app, and
|
||||
/// the instance names this project's source. Todo keeps nothing of a person's
|
||||
/// yet, so it deletes nothing of its own with them. The server sets it up
|
||||
/// before it starts (`server.dart`), and so do its tests.
|
||||
HalkyonBase todoBase() => HalkyonBase(
|
||||
app: 'todo',
|
||||
appName: 'Halkyon Todo',
|
||||
upstreamSourceCodeUrl: upstreamSourceCodeUrl,
|
||||
minimumAppBuild: minimumAppBuild,
|
||||
);
|
||||
/// yet, so it deletes nothing of its own with them. It holds the instance's
|
||||
/// register, or is a member of the one [accounts] names (ADR 0016; the
|
||||
/// server reads it from the operator's environment, `ACCOUNT_REGISTER_URL`).
|
||||
/// The server sets it up before it starts (`server.dart`), and so do its
|
||||
/// tests.
|
||||
HalkyonBase todoBase({AccountsMode accounts = const HoldsRegister()}) =>
|
||||
HalkyonBase(
|
||||
app: 'todo',
|
||||
appName: 'Halkyon Todo',
|
||||
upstreamSourceCodeUrl: upstreamSourceCodeUrl,
|
||||
minimumAppBuild: minimumAppBuild,
|
||||
accounts: accounts,
|
||||
);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,888 @@
|
|||
BEGIN;
|
||||
|
||||
--
|
||||
-- Function: gen_random_uuid_v7()
|
||||
-- Source: https://gist.github.com/kjmph/5bd772b2c2df145aa645b837da7eca74
|
||||
-- License: MIT (copyright notice included on the generator source code).
|
||||
--
|
||||
create or replace function gen_random_uuid_v7()
|
||||
returns uuid
|
||||
as $$
|
||||
begin
|
||||
-- use random v4 uuid as starting point (which has the same variant we need)
|
||||
-- then overlay timestamp
|
||||
-- then set version 7 by flipping the 2 and 1 bit in the version 4 string
|
||||
return encode(
|
||||
set_bit(
|
||||
set_bit(
|
||||
overlay(uuid_send(gen_random_uuid())
|
||||
placing substring(int8send(floor(extract(epoch from clock_timestamp()) * 1000)::bigint) from 3)
|
||||
from 1 for 6
|
||||
),
|
||||
52, 1
|
||||
),
|
||||
53, 1
|
||||
),
|
||||
'hex')::uuid;
|
||||
end
|
||||
$$
|
||||
language plpgsql
|
||||
volatile;
|
||||
|
||||
--
|
||||
-- Class AccountDeletionNotice as table account_deletion_notice
|
||||
--
|
||||
CREATE TABLE "account_deletion_notice" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"account" uuid NOT NULL,
|
||||
"member" text NOT NULL,
|
||||
"createdAt" timestamp without time zone NOT NULL,
|
||||
"attempts" bigint NOT NULL,
|
||||
"lastAttemptAt" timestamp without time zone
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "account_deletion_notice_idx" ON "account_deletion_notice" USING btree ("account", "member");
|
||||
|
||||
--
|
||||
-- Class EmailCodeRequest as table email_code_request
|
||||
--
|
||||
CREATE TABLE "email_code_request" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid_v7(),
|
||||
"addressHash" text NOT NULL,
|
||||
"challengeId" uuid NOT NULL,
|
||||
"switchChallengeId" uuid,
|
||||
"createdAt" timestamp without time zone NOT NULL
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE INDEX "email_code_request_address_idx" ON "email_code_request" USING btree ("addressHash");
|
||||
|
||||
--
|
||||
-- Class EmailIdentity as table email_identity
|
||||
--
|
||||
CREATE TABLE "email_identity" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"authUserId" uuid NOT NULL,
|
||||
"addressHash" text NOT NULL,
|
||||
"createdAt" timestamp without time zone NOT NULL
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "email_identity_person_idx" ON "email_identity" USING btree ("authUserId");
|
||||
CREATE UNIQUE INDEX "email_identity_address_idx" ON "email_identity" USING btree ("addressHash");
|
||||
|
||||
--
|
||||
-- Class PublicProfile as table public_profile
|
||||
--
|
||||
CREATE TABLE "public_profile" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"authUserId" uuid NOT NULL,
|
||||
"handle" text NOT NULL,
|
||||
"handleKey" text NOT NULL,
|
||||
"displayName" text NOT NULL,
|
||||
"bio" text NOT NULL,
|
||||
"links" json NOT NULL,
|
||||
"verifiedLinks" json,
|
||||
"avatarHash" text,
|
||||
"firstPublishedAt" timestamp without time zone,
|
||||
"updatedAt" timestamp without time zone NOT NULL
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "public_profile_person_idx" ON "public_profile" USING btree ("authUserId");
|
||||
CREATE UNIQUE INDEX "public_profile_handle_idx" ON "public_profile" USING btree ("handleKey");
|
||||
|
||||
--
|
||||
-- Class CloudStorageEntry as table serverpod_cloud_storage
|
||||
--
|
||||
CREATE TABLE "serverpod_cloud_storage" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"storageId" text NOT NULL,
|
||||
"path" text NOT NULL,
|
||||
"addedTime" timestamp without time zone NOT NULL,
|
||||
"expiration" timestamp without time zone,
|
||||
"byteData" bytea NOT NULL,
|
||||
"verified" boolean NOT NULL,
|
||||
"contentType" text,
|
||||
"cacheControl" text,
|
||||
"contentDisposition" text,
|
||||
"contentEncoding" text,
|
||||
"customMetadata" text
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "serverpod_cloud_storage_path_idx" ON "serverpod_cloud_storage" USING btree ("storageId", "path");
|
||||
CREATE INDEX "serverpod_cloud_storage_expiration" ON "serverpod_cloud_storage" USING btree ("expiration");
|
||||
|
||||
--
|
||||
-- Class CloudStorageDirectDownloadEntry as table serverpod_cloud_storage_direct_download
|
||||
--
|
||||
CREATE TABLE "serverpod_cloud_storage_direct_download" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"storageId" text NOT NULL,
|
||||
"path" text NOT NULL,
|
||||
"expiration" timestamp without time zone NOT NULL,
|
||||
"authKey" text NOT NULL,
|
||||
"downloadFileName" text,
|
||||
"contentType" text
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "serverpod_cloud_storage_direct_download_auth_key" ON "serverpod_cloud_storage_direct_download" USING btree ("authKey");
|
||||
CREATE INDEX "serverpod_cloud_storage_direct_download_expiration" ON "serverpod_cloud_storage_direct_download" USING btree ("expiration");
|
||||
|
||||
--
|
||||
-- Class CloudStorageDirectUploadEntry as table serverpod_cloud_storage_direct_upload
|
||||
--
|
||||
CREATE TABLE "serverpod_cloud_storage_direct_upload" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"storageId" text NOT NULL,
|
||||
"path" text NOT NULL,
|
||||
"expiration" timestamp without time zone NOT NULL,
|
||||
"authKey" text NOT NULL,
|
||||
"maxFileSize" bigint NOT NULL DEFAULT 10485760,
|
||||
"contentLength" bigint,
|
||||
"preventOverwrite" boolean NOT NULL DEFAULT false,
|
||||
"contentType" text,
|
||||
"cacheControl" text,
|
||||
"contentDisposition" text,
|
||||
"contentEncoding" text,
|
||||
"customMetadata" text
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "serverpod_cloud_storage_direct_upload_storage_path" ON "serverpod_cloud_storage_direct_upload" USING btree ("storageId", "path");
|
||||
|
||||
--
|
||||
-- Class FutureCallEntry as table serverpod_future_call
|
||||
--
|
||||
CREATE TABLE "serverpod_future_call" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"name" text NOT NULL,
|
||||
"time" timestamp without time zone NOT NULL,
|
||||
"serializedObject" text,
|
||||
"serverId" text NOT NULL,
|
||||
"identifier" text,
|
||||
"scheduling" json
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE INDEX "serverpod_future_call_time_idx" ON "serverpod_future_call" USING btree ("time");
|
||||
CREATE INDEX "serverpod_future_call_serverId_idx" ON "serverpod_future_call" USING btree ("serverId");
|
||||
CREATE INDEX "serverpod_future_call_identifier_idx" ON "serverpod_future_call" USING btree ("identifier");
|
||||
|
||||
--
|
||||
-- Class FutureCallClaimEntry as table serverpod_future_call_claim
|
||||
--
|
||||
CREATE TABLE "serverpod_future_call_claim" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"futureCallId" bigint,
|
||||
"lastHeartbeatTime" timestamp without time zone NOT NULL
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "future_call_unique_idx" ON "serverpod_future_call_claim" USING btree ("futureCallId");
|
||||
|
||||
--
|
||||
-- Class ServerHealthConnectionInfo as table serverpod_health_connection_info
|
||||
--
|
||||
CREATE TABLE "serverpod_health_connection_info" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"serverId" text NOT NULL,
|
||||
"timestamp" timestamp without time zone NOT NULL,
|
||||
"active" bigint NOT NULL,
|
||||
"closing" bigint NOT NULL,
|
||||
"idle" bigint NOT NULL,
|
||||
"granularity" bigint NOT NULL
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "serverpod_health_connection_info_timestamp_idx" ON "serverpod_health_connection_info" USING btree ("timestamp", "serverId", "granularity");
|
||||
|
||||
--
|
||||
-- Class ServerHealthMetric as table serverpod_health_metric
|
||||
--
|
||||
CREATE TABLE "serverpod_health_metric" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"name" text NOT NULL,
|
||||
"serverId" text NOT NULL,
|
||||
"timestamp" timestamp without time zone NOT NULL,
|
||||
"isHealthy" boolean NOT NULL,
|
||||
"value" double precision NOT NULL,
|
||||
"granularity" bigint NOT NULL
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "serverpod_health_metric_timestamp_idx" ON "serverpod_health_metric" USING btree ("timestamp", "serverId", "name", "granularity");
|
||||
|
||||
--
|
||||
-- Class LogEntry as table serverpod_log
|
||||
--
|
||||
CREATE TABLE "serverpod_log" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"sessionLogId" bigint NOT NULL,
|
||||
"messageId" bigint,
|
||||
"reference" text,
|
||||
"serverId" text NOT NULL,
|
||||
"time" timestamp without time zone NOT NULL,
|
||||
"logLevel" bigint NOT NULL,
|
||||
"message" text NOT NULL,
|
||||
"error" text,
|
||||
"stackTrace" text,
|
||||
"order" bigint NOT NULL
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE INDEX "serverpod_log_sessionLogId_idx" ON "serverpod_log" USING btree ("sessionLogId", "order");
|
||||
|
||||
--
|
||||
-- Class MessageLogEntry as table serverpod_message_log
|
||||
--
|
||||
CREATE TABLE "serverpod_message_log" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"sessionLogId" bigint NOT NULL,
|
||||
"serverId" text NOT NULL,
|
||||
"messageId" bigint NOT NULL,
|
||||
"endpoint" text NOT NULL,
|
||||
"messageName" text NOT NULL,
|
||||
"duration" double precision NOT NULL,
|
||||
"error" text,
|
||||
"stackTrace" text,
|
||||
"slow" boolean NOT NULL,
|
||||
"order" bigint NOT NULL
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE INDEX "serverpod_message_log_sessionLogId_idx" ON "serverpod_message_log" USING btree ("sessionLogId", "order");
|
||||
|
||||
--
|
||||
-- Class MethodInfo as table serverpod_method
|
||||
--
|
||||
CREATE TABLE "serverpod_method" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"endpoint" text NOT NULL,
|
||||
"method" text NOT NULL
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "serverpod_method_endpoint_method_idx" ON "serverpod_method" USING btree ("endpoint", "method");
|
||||
|
||||
--
|
||||
-- Class DatabaseMigrationVersion as table serverpod_migrations
|
||||
--
|
||||
CREATE TABLE "serverpod_migrations" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"module" text NOT NULL,
|
||||
"version" text NOT NULL,
|
||||
"timestamp" timestamp without time zone
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "serverpod_migrations_ids" ON "serverpod_migrations" USING btree ("module");
|
||||
|
||||
--
|
||||
-- Class QueryLogEntry as table serverpod_query_log
|
||||
--
|
||||
CREATE TABLE "serverpod_query_log" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"serverId" text NOT NULL,
|
||||
"sessionLogId" bigint NOT NULL,
|
||||
"messageId" bigint,
|
||||
"query" text NOT NULL,
|
||||
"duration" double precision NOT NULL,
|
||||
"numRows" bigint,
|
||||
"error" text,
|
||||
"stackTrace" text,
|
||||
"slow" boolean NOT NULL,
|
||||
"order" bigint NOT NULL
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE INDEX "serverpod_query_log_sessionLogId_idx" ON "serverpod_query_log" USING btree ("sessionLogId", "order");
|
||||
|
||||
--
|
||||
-- Class ReadWriteTestEntry as table serverpod_readwrite_test
|
||||
--
|
||||
CREATE TABLE "serverpod_readwrite_test" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"number" bigint NOT NULL
|
||||
);
|
||||
|
||||
--
|
||||
-- Class RuntimeSettings as table serverpod_runtime_settings
|
||||
--
|
||||
CREATE TABLE "serverpod_runtime_settings" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"logSettings" json NOT NULL,
|
||||
"logSettingsOverrides" json NOT NULL,
|
||||
"logServiceCalls" boolean NOT NULL,
|
||||
"logMalformedCalls" boolean NOT NULL
|
||||
);
|
||||
|
||||
--
|
||||
-- Class SessionLogEntry as table serverpod_session_log
|
||||
--
|
||||
CREATE TABLE "serverpod_session_log" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"serverId" text NOT NULL,
|
||||
"time" timestamp without time zone NOT NULL,
|
||||
"module" text,
|
||||
"endpoint" text,
|
||||
"method" text,
|
||||
"duration" double precision,
|
||||
"numQueries" bigint,
|
||||
"slow" boolean,
|
||||
"error" text,
|
||||
"stackTrace" text,
|
||||
"authenticatedUserId" bigint,
|
||||
"userId" text,
|
||||
"isOpen" boolean,
|
||||
"touched" timestamp without time zone NOT NULL
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE INDEX "serverpod_session_log_serverid_idx" ON "serverpod_session_log" USING btree ("serverId");
|
||||
CREATE INDEX "serverpod_session_log_time_idx" ON "serverpod_session_log" USING btree ("time");
|
||||
CREATE INDEX "serverpod_session_log_touched_idx" ON "serverpod_session_log" USING btree ("touched");
|
||||
CREATE INDEX "serverpod_session_log_isopen_idx" ON "serverpod_session_log" USING btree ("isOpen");
|
||||
|
||||
--
|
||||
-- Class AnonymousAccount as table serverpod_auth_idp_anonymous_account
|
||||
--
|
||||
CREATE TABLE "serverpod_auth_idp_anonymous_account" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid_v7(),
|
||||
"authUserId" uuid NOT NULL,
|
||||
"createdAt" timestamp without time zone NOT NULL
|
||||
);
|
||||
|
||||
--
|
||||
-- Class AppleAccount as table serverpod_auth_idp_apple_account
|
||||
--
|
||||
CREATE TABLE "serverpod_auth_idp_apple_account" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid_v7(),
|
||||
"userIdentifier" text NOT NULL,
|
||||
"refreshToken" text NOT NULL,
|
||||
"refreshTokenRequestedWithBundleIdentifier" boolean NOT NULL,
|
||||
"lastRefreshedAt" timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"authUserId" uuid NOT NULL,
|
||||
"createdAt" timestamp without time zone NOT NULL,
|
||||
"email" text,
|
||||
"isEmailVerified" boolean,
|
||||
"isPrivateEmail" boolean,
|
||||
"firstName" text,
|
||||
"lastName" text
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "serverpod_auth_apple_account_identifier" ON "serverpod_auth_idp_apple_account" USING btree ("userIdentifier");
|
||||
|
||||
--
|
||||
-- Class EmailAccount as table serverpod_auth_idp_email_account
|
||||
--
|
||||
CREATE TABLE "serverpod_auth_idp_email_account" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid_v7(),
|
||||
"authUserId" uuid NOT NULL,
|
||||
"createdAt" timestamp without time zone NOT NULL,
|
||||
"email" text NOT NULL,
|
||||
"passwordHash" text NOT NULL
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "serverpod_auth_idp_email_account_email" ON "serverpod_auth_idp_email_account" USING btree ("email");
|
||||
|
||||
--
|
||||
-- Class EmailAccountPasswordResetRequest as table serverpod_auth_idp_email_account_password_reset_request
|
||||
--
|
||||
CREATE TABLE "serverpod_auth_idp_email_account_password_reset_request" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid_v7(),
|
||||
"emailAccountId" uuid NOT NULL,
|
||||
"createdAt" timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"challengeId" uuid NOT NULL,
|
||||
"setPasswordChallengeId" uuid
|
||||
);
|
||||
|
||||
--
|
||||
-- Class EmailAccountRequest as table serverpod_auth_idp_email_account_request
|
||||
--
|
||||
CREATE TABLE "serverpod_auth_idp_email_account_request" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid_v7(),
|
||||
"createdAt" timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"email" text NOT NULL,
|
||||
"challengeId" uuid NOT NULL,
|
||||
"createAccountChallengeId" uuid
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "serverpod_auth_idp_email_account_request_email" ON "serverpod_auth_idp_email_account_request" USING btree ("email");
|
||||
|
||||
--
|
||||
-- Class FacebookAccount as table serverpod_auth_idp_facebook_account
|
||||
--
|
||||
CREATE TABLE "serverpod_auth_idp_facebook_account" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid_v7(),
|
||||
"authUserId" uuid NOT NULL,
|
||||
"createdAt" timestamp without time zone NOT NULL,
|
||||
"userIdentifier" text NOT NULL,
|
||||
"email" text,
|
||||
"fullName" text,
|
||||
"firstName" text,
|
||||
"lastName" text
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "serverpod_auth_facebook_account_user_identifier" ON "serverpod_auth_idp_facebook_account" USING btree ("userIdentifier");
|
||||
|
||||
--
|
||||
-- Class FirebaseAccount as table serverpod_auth_idp_firebase_account
|
||||
--
|
||||
CREATE TABLE "serverpod_auth_idp_firebase_account" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid_v7(),
|
||||
"authUserId" uuid NOT NULL,
|
||||
"created" timestamp without time zone NOT NULL,
|
||||
"email" text,
|
||||
"phone" text,
|
||||
"userIdentifier" text NOT NULL
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "serverpod_auth_firebase_account_user_identifier" ON "serverpod_auth_idp_firebase_account" USING btree ("userIdentifier");
|
||||
|
||||
--
|
||||
-- Class GitHubAccount as table serverpod_auth_idp_github_account
|
||||
--
|
||||
CREATE TABLE "serverpod_auth_idp_github_account" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid_v7(),
|
||||
"authUserId" uuid NOT NULL,
|
||||
"userIdentifier" text NOT NULL,
|
||||
"email" text,
|
||||
"created" timestamp without time zone NOT NULL
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "serverpod_auth_github_account_user_identifier" ON "serverpod_auth_idp_github_account" USING btree ("userIdentifier");
|
||||
|
||||
--
|
||||
-- Class GoogleAccount as table serverpod_auth_idp_google_account
|
||||
--
|
||||
CREATE TABLE "serverpod_auth_idp_google_account" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid_v7(),
|
||||
"authUserId" uuid NOT NULL,
|
||||
"created" timestamp without time zone NOT NULL,
|
||||
"email" text NOT NULL,
|
||||
"userIdentifier" text NOT NULL
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "serverpod_auth_google_account_user_identifier" ON "serverpod_auth_idp_google_account" USING btree ("userIdentifier");
|
||||
|
||||
--
|
||||
-- Class MicrosoftAccount as table serverpod_auth_idp_microsoft_account
|
||||
--
|
||||
CREATE TABLE "serverpod_auth_idp_microsoft_account" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid_v7(),
|
||||
"authUserId" uuid NOT NULL,
|
||||
"userIdentifier" text NOT NULL,
|
||||
"email" text,
|
||||
"created" timestamp without time zone NOT NULL
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "serverpod_auth_microsoft_account_user_identifier" ON "serverpod_auth_idp_microsoft_account" USING btree ("userIdentifier");
|
||||
|
||||
--
|
||||
-- Class PasskeyAccount as table serverpod_auth_idp_passkey_account
|
||||
--
|
||||
CREATE TABLE "serverpod_auth_idp_passkey_account" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid_v7(),
|
||||
"authUserId" uuid NOT NULL,
|
||||
"createdAt" timestamp without time zone NOT NULL,
|
||||
"keyId" bytea NOT NULL,
|
||||
"keyIdBase64" text NOT NULL,
|
||||
"clientDataJSON" bytea NOT NULL,
|
||||
"attestationObject" bytea NOT NULL,
|
||||
"originalChallenge" bytea NOT NULL
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "serverpod_auth_idp_passkey_account_key_id_base64" ON "serverpod_auth_idp_passkey_account" USING btree ("keyIdBase64");
|
||||
|
||||
--
|
||||
-- Class PasskeyChallenge as table serverpod_auth_idp_passkey_challenge
|
||||
--
|
||||
CREATE TABLE "serverpod_auth_idp_passkey_challenge" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid_v7(),
|
||||
"createdAt" timestamp without time zone NOT NULL,
|
||||
"challenge" bytea NOT NULL
|
||||
);
|
||||
|
||||
--
|
||||
-- Class RateLimitedRequestAttempt as table serverpod_auth_idp_rate_limited_request_attempt
|
||||
--
|
||||
CREATE TABLE "serverpod_auth_idp_rate_limited_request_attempt" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid_v7(),
|
||||
"domain" text NOT NULL,
|
||||
"source" text NOT NULL,
|
||||
"key" text NOT NULL,
|
||||
"ipAddress" text,
|
||||
"attemptedAt" timestamp without time zone NOT NULL,
|
||||
"extraData" json
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE INDEX "serverpod_auth_idp_rate_limited_request_attempt_composite" ON "serverpod_auth_idp_rate_limited_request_attempt" USING btree ("domain", "source", "key", "attemptedAt");
|
||||
|
||||
--
|
||||
-- Class SecretChallenge as table serverpod_auth_idp_secret_challenge
|
||||
--
|
||||
CREATE TABLE "serverpod_auth_idp_secret_challenge" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid_v7(),
|
||||
"challengeCodeHash" text NOT NULL
|
||||
);
|
||||
|
||||
--
|
||||
-- Class RefreshToken as table serverpod_auth_core_jwt_refresh_token
|
||||
--
|
||||
CREATE TABLE "serverpod_auth_core_jwt_refresh_token" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid_v7(),
|
||||
"authUserId" uuid NOT NULL,
|
||||
"scopeNames" json NOT NULL,
|
||||
"extraClaims" text,
|
||||
"method" text NOT NULL,
|
||||
"fixedSecret" bytea NOT NULL,
|
||||
"rotatingSecretHash" text NOT NULL,
|
||||
"lastUpdatedAt" timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"createdAt" timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE INDEX "serverpod_auth_core_jwt_refresh_token_last_updated_at" ON "serverpod_auth_core_jwt_refresh_token" USING btree ("lastUpdatedAt");
|
||||
|
||||
--
|
||||
-- Class UserProfile as table serverpod_auth_core_profile
|
||||
--
|
||||
CREATE TABLE "serverpod_auth_core_profile" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid_v7(),
|
||||
"authUserId" uuid NOT NULL,
|
||||
"userName" text,
|
||||
"fullName" text,
|
||||
"email" text,
|
||||
"createdAt" timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"imageId" uuid
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "serverpod_auth_profile_user_profile_email_auth_user_id" ON "serverpod_auth_core_profile" USING btree ("authUserId");
|
||||
|
||||
--
|
||||
-- Class UserProfileImage as table serverpod_auth_core_profile_image
|
||||
--
|
||||
CREATE TABLE "serverpod_auth_core_profile_image" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid_v7(),
|
||||
"userProfileId" uuid NOT NULL,
|
||||
"createdAt" timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"storageId" text NOT NULL,
|
||||
"path" text NOT NULL,
|
||||
"url" text NOT NULL
|
||||
);
|
||||
|
||||
--
|
||||
-- Class ServerSideSession as table serverpod_auth_core_session
|
||||
--
|
||||
CREATE TABLE "serverpod_auth_core_session" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid_v7(),
|
||||
"authUserId" uuid NOT NULL,
|
||||
"scopeNames" json NOT NULL,
|
||||
"createdAt" timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"lastUsedAt" timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"expiresAt" timestamp without time zone,
|
||||
"expireAfterUnusedFor" bigint,
|
||||
"sessionKeyHash" bytea NOT NULL,
|
||||
"sessionKeySalt" bytea NOT NULL,
|
||||
"method" text NOT NULL
|
||||
);
|
||||
|
||||
--
|
||||
-- Class AuthUser as table serverpod_auth_core_user
|
||||
--
|
||||
CREATE TABLE "serverpod_auth_core_user" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid_v7(),
|
||||
"createdAt" timestamp without time zone NOT NULL,
|
||||
"scopeNames" json NOT NULL,
|
||||
"blocked" boolean NOT NULL
|
||||
);
|
||||
|
||||
--
|
||||
-- Foreign relations for "email_code_request" table
|
||||
--
|
||||
ALTER TABLE ONLY "email_code_request"
|
||||
ADD CONSTRAINT "email_code_request_fk_0"
|
||||
FOREIGN KEY("challengeId")
|
||||
REFERENCES "serverpod_auth_idp_secret_challenge"("id")
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION;
|
||||
ALTER TABLE ONLY "email_code_request"
|
||||
ADD CONSTRAINT "email_code_request_fk_1"
|
||||
FOREIGN KEY("switchChallengeId")
|
||||
REFERENCES "serverpod_auth_idp_secret_challenge"("id")
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION;
|
||||
|
||||
--
|
||||
-- Foreign relations for "serverpod_future_call_claim" table
|
||||
--
|
||||
ALTER TABLE ONLY "serverpod_future_call_claim"
|
||||
ADD CONSTRAINT "serverpod_future_call_claim_fk_0"
|
||||
FOREIGN KEY("futureCallId")
|
||||
REFERENCES "serverpod_future_call"("id")
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION;
|
||||
|
||||
--
|
||||
-- Foreign relations for "serverpod_log" table
|
||||
--
|
||||
ALTER TABLE ONLY "serverpod_log"
|
||||
ADD CONSTRAINT "serverpod_log_fk_0"
|
||||
FOREIGN KEY("sessionLogId")
|
||||
REFERENCES "serverpod_session_log"("id")
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION;
|
||||
|
||||
--
|
||||
-- Foreign relations for "serverpod_message_log" table
|
||||
--
|
||||
ALTER TABLE ONLY "serverpod_message_log"
|
||||
ADD CONSTRAINT "serverpod_message_log_fk_0"
|
||||
FOREIGN KEY("sessionLogId")
|
||||
REFERENCES "serverpod_session_log"("id")
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION;
|
||||
|
||||
--
|
||||
-- Foreign relations for "serverpod_query_log" table
|
||||
--
|
||||
ALTER TABLE ONLY "serverpod_query_log"
|
||||
ADD CONSTRAINT "serverpod_query_log_fk_0"
|
||||
FOREIGN KEY("sessionLogId")
|
||||
REFERENCES "serverpod_session_log"("id")
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION;
|
||||
|
||||
--
|
||||
-- Foreign relations for "serverpod_auth_idp_anonymous_account" table
|
||||
--
|
||||
ALTER TABLE ONLY "serverpod_auth_idp_anonymous_account"
|
||||
ADD CONSTRAINT "serverpod_auth_idp_anonymous_account_fk_0"
|
||||
FOREIGN KEY("authUserId")
|
||||
REFERENCES "serverpod_auth_core_user"("id")
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION;
|
||||
|
||||
--
|
||||
-- Foreign relations for "serverpod_auth_idp_apple_account" table
|
||||
--
|
||||
ALTER TABLE ONLY "serverpod_auth_idp_apple_account"
|
||||
ADD CONSTRAINT "serverpod_auth_idp_apple_account_fk_0"
|
||||
FOREIGN KEY("authUserId")
|
||||
REFERENCES "serverpod_auth_core_user"("id")
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION;
|
||||
|
||||
--
|
||||
-- Foreign relations for "serverpod_auth_idp_email_account" table
|
||||
--
|
||||
ALTER TABLE ONLY "serverpod_auth_idp_email_account"
|
||||
ADD CONSTRAINT "serverpod_auth_idp_email_account_fk_0"
|
||||
FOREIGN KEY("authUserId")
|
||||
REFERENCES "serverpod_auth_core_user"("id")
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION;
|
||||
|
||||
--
|
||||
-- Foreign relations for "serverpod_auth_idp_email_account_password_reset_request" table
|
||||
--
|
||||
ALTER TABLE ONLY "serverpod_auth_idp_email_account_password_reset_request"
|
||||
ADD CONSTRAINT "serverpod_auth_idp_email_account_password_reset_request_fk_0"
|
||||
FOREIGN KEY("emailAccountId")
|
||||
REFERENCES "serverpod_auth_idp_email_account"("id")
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION;
|
||||
ALTER TABLE ONLY "serverpod_auth_idp_email_account_password_reset_request"
|
||||
ADD CONSTRAINT "serverpod_auth_idp_email_account_password_reset_request_fk_1"
|
||||
FOREIGN KEY("challengeId")
|
||||
REFERENCES "serverpod_auth_idp_secret_challenge"("id")
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION;
|
||||
ALTER TABLE ONLY "serverpod_auth_idp_email_account_password_reset_request"
|
||||
ADD CONSTRAINT "serverpod_auth_idp_email_account_password_reset_request_fk_2"
|
||||
FOREIGN KEY("setPasswordChallengeId")
|
||||
REFERENCES "serverpod_auth_idp_secret_challenge"("id")
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION;
|
||||
|
||||
--
|
||||
-- Foreign relations for "serverpod_auth_idp_email_account_request" table
|
||||
--
|
||||
ALTER TABLE ONLY "serverpod_auth_idp_email_account_request"
|
||||
ADD CONSTRAINT "serverpod_auth_idp_email_account_request_fk_0"
|
||||
FOREIGN KEY("challengeId")
|
||||
REFERENCES "serverpod_auth_idp_secret_challenge"("id")
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION;
|
||||
ALTER TABLE ONLY "serverpod_auth_idp_email_account_request"
|
||||
ADD CONSTRAINT "serverpod_auth_idp_email_account_request_fk_1"
|
||||
FOREIGN KEY("createAccountChallengeId")
|
||||
REFERENCES "serverpod_auth_idp_secret_challenge"("id")
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION;
|
||||
|
||||
--
|
||||
-- Foreign relations for "serverpod_auth_idp_facebook_account" table
|
||||
--
|
||||
ALTER TABLE ONLY "serverpod_auth_idp_facebook_account"
|
||||
ADD CONSTRAINT "serverpod_auth_idp_facebook_account_fk_0"
|
||||
FOREIGN KEY("authUserId")
|
||||
REFERENCES "serverpod_auth_core_user"("id")
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION;
|
||||
|
||||
--
|
||||
-- Foreign relations for "serverpod_auth_idp_firebase_account" table
|
||||
--
|
||||
ALTER TABLE ONLY "serverpod_auth_idp_firebase_account"
|
||||
ADD CONSTRAINT "serverpod_auth_idp_firebase_account_fk_0"
|
||||
FOREIGN KEY("authUserId")
|
||||
REFERENCES "serverpod_auth_core_user"("id")
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION;
|
||||
|
||||
--
|
||||
-- Foreign relations for "serverpod_auth_idp_github_account" table
|
||||
--
|
||||
ALTER TABLE ONLY "serverpod_auth_idp_github_account"
|
||||
ADD CONSTRAINT "serverpod_auth_idp_github_account_fk_0"
|
||||
FOREIGN KEY("authUserId")
|
||||
REFERENCES "serverpod_auth_core_user"("id")
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION;
|
||||
|
||||
--
|
||||
-- Foreign relations for "serverpod_auth_idp_google_account" table
|
||||
--
|
||||
ALTER TABLE ONLY "serverpod_auth_idp_google_account"
|
||||
ADD CONSTRAINT "serverpod_auth_idp_google_account_fk_0"
|
||||
FOREIGN KEY("authUserId")
|
||||
REFERENCES "serverpod_auth_core_user"("id")
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION;
|
||||
|
||||
--
|
||||
-- Foreign relations for "serverpod_auth_idp_microsoft_account" table
|
||||
--
|
||||
ALTER TABLE ONLY "serverpod_auth_idp_microsoft_account"
|
||||
ADD CONSTRAINT "serverpod_auth_idp_microsoft_account_fk_0"
|
||||
FOREIGN KEY("authUserId")
|
||||
REFERENCES "serverpod_auth_core_user"("id")
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION;
|
||||
|
||||
--
|
||||
-- Foreign relations for "serverpod_auth_idp_passkey_account" table
|
||||
--
|
||||
ALTER TABLE ONLY "serverpod_auth_idp_passkey_account"
|
||||
ADD CONSTRAINT "serverpod_auth_idp_passkey_account_fk_0"
|
||||
FOREIGN KEY("authUserId")
|
||||
REFERENCES "serverpod_auth_core_user"("id")
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION;
|
||||
|
||||
--
|
||||
-- Foreign relations for "serverpod_auth_core_jwt_refresh_token" table
|
||||
--
|
||||
ALTER TABLE ONLY "serverpod_auth_core_jwt_refresh_token"
|
||||
ADD CONSTRAINT "serverpod_auth_core_jwt_refresh_token_fk_0"
|
||||
FOREIGN KEY("authUserId")
|
||||
REFERENCES "serverpod_auth_core_user"("id")
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION;
|
||||
|
||||
--
|
||||
-- Foreign relations for "serverpod_auth_core_profile" table
|
||||
--
|
||||
ALTER TABLE ONLY "serverpod_auth_core_profile"
|
||||
ADD CONSTRAINT "serverpod_auth_core_profile_fk_0"
|
||||
FOREIGN KEY("authUserId")
|
||||
REFERENCES "serverpod_auth_core_user"("id")
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION;
|
||||
ALTER TABLE ONLY "serverpod_auth_core_profile"
|
||||
ADD CONSTRAINT "serverpod_auth_core_profile_fk_1"
|
||||
FOREIGN KEY("imageId")
|
||||
REFERENCES "serverpod_auth_core_profile_image"("id")
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION
|
||||
DEFERRABLE INITIALLY DEFERRED;
|
||||
|
||||
--
|
||||
-- Foreign relations for "serverpod_auth_core_profile_image" table
|
||||
--
|
||||
ALTER TABLE ONLY "serverpod_auth_core_profile_image"
|
||||
ADD CONSTRAINT "serverpod_auth_core_profile_image_fk_0"
|
||||
FOREIGN KEY("userProfileId")
|
||||
REFERENCES "serverpod_auth_core_profile"("id")
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION;
|
||||
|
||||
--
|
||||
-- Foreign relations for "serverpod_auth_core_session" table
|
||||
--
|
||||
ALTER TABLE ONLY "serverpod_auth_core_session"
|
||||
ADD CONSTRAINT "serverpod_auth_core_session_fk_0"
|
||||
FOREIGN KEY("authUserId")
|
||||
REFERENCES "serverpod_auth_core_user"("id")
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION;
|
||||
|
||||
|
||||
--
|
||||
-- MIGRATION VERSION FOR halkyon_todo
|
||||
--
|
||||
INSERT INTO "serverpod_migrations" ("module", "version", "timestamp")
|
||||
VALUES ('halkyon_todo', '20261019204122341-deletion-notices', now())
|
||||
ON CONFLICT ("module")
|
||||
DO UPDATE SET "version" = '20261019204122341-deletion-notices', "timestamp" = now();
|
||||
|
||||
--
|
||||
-- MIGRATION VERSION FOR halkyon_base
|
||||
--
|
||||
INSERT INTO "serverpod_migrations" ("module", "version", "timestamp")
|
||||
VALUES ('halkyon_base', '20261019202835333-deletion-notices', now())
|
||||
ON CONFLICT ("module")
|
||||
DO UPDATE SET "version" = '20261019202835333-deletion-notices', "timestamp" = now();
|
||||
|
||||
--
|
||||
-- MIGRATION VERSION FOR serverpod
|
||||
--
|
||||
INSERT INTO "serverpod_migrations" ("module", "version", "timestamp")
|
||||
VALUES ('serverpod', '20260824182259319', now())
|
||||
ON CONFLICT ("module")
|
||||
DO UPDATE SET "version" = '20260824182259319', "timestamp" = now();
|
||||
|
||||
--
|
||||
-- MIGRATION VERSION FOR serverpod_auth_idp
|
||||
--
|
||||
INSERT INTO "serverpod_migrations" ("module", "version", "timestamp")
|
||||
VALUES ('serverpod_auth_idp', '20260924105404509', now())
|
||||
ON CONFLICT ("module")
|
||||
DO UPDATE SET "version" = '20260924105404509', "timestamp" = now();
|
||||
|
||||
--
|
||||
-- MIGRATION VERSION FOR serverpod_auth_core
|
||||
--
|
||||
INSERT INTO "serverpod_migrations" ("module", "version", "timestamp")
|
||||
VALUES ('serverpod_auth_core', '20260924105232991', now())
|
||||
ON CONFLICT ("module")
|
||||
DO UPDATE SET "version" = '20260924105232991', "timestamp" = now();
|
||||
|
||||
|
||||
COMMIT;
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"__className__": "serverpod.DatabaseDefinition",
|
||||
"schemaVersion": 2,
|
||||
"moduleName": "halkyon_todo",
|
||||
"tables": [],
|
||||
"installedModules": [
|
||||
{
|
||||
"__className__": "serverpod.DatabaseMigrationVersion",
|
||||
"module": "halkyon_base",
|
||||
"version": "20261019202835333-deletion-notices"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.DatabaseMigrationVersion",
|
||||
"module": "serverpod",
|
||||
"version": "20260824182259319"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.DatabaseMigrationVersion",
|
||||
"module": "serverpod_auth_idp",
|
||||
"version": "20260924105404509"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.DatabaseMigrationVersion",
|
||||
"module": "serverpod_auth_core",
|
||||
"version": "20260924105232991"
|
||||
}
|
||||
],
|
||||
"migrationApiVersion": 1
|
||||
}
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
{
|
||||
"__className__": "serverpod.DatabaseMigration",
|
||||
"actions": [
|
||||
{
|
||||
"__className__": "serverpod.DatabaseMigrationAction",
|
||||
"type": "createTable",
|
||||
"createTable": {
|
||||
"__className__": "serverpod.TableDefinition",
|
||||
"name": "account_deletion_notice",
|
||||
"dartName": "AccountDeletionNotice",
|
||||
"module": "halkyon_base",
|
||||
"schema": "public",
|
||||
"columns": [
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "id",
|
||||
"fieldName": "id",
|
||||
"columnType": 6,
|
||||
"isNullable": false,
|
||||
"columnDefault": "serial",
|
||||
"dartType": "int?"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "account",
|
||||
"fieldName": "account",
|
||||
"columnType": 7,
|
||||
"isNullable": false,
|
||||
"dartType": "UuidValue"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "member",
|
||||
"fieldName": "member",
|
||||
"columnType": 0,
|
||||
"isNullable": false,
|
||||
"dartType": "String"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "createdAt",
|
||||
"fieldName": "createdAt",
|
||||
"columnType": 4,
|
||||
"isNullable": false,
|
||||
"dartType": "DateTime"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "attempts",
|
||||
"fieldName": "attempts",
|
||||
"columnType": 6,
|
||||
"isNullable": false,
|
||||
"dartType": "int"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.ColumnDefinition",
|
||||
"name": "lastAttemptAt",
|
||||
"fieldName": "lastAttemptAt",
|
||||
"columnType": 4,
|
||||
"isNullable": true,
|
||||
"dartType": "DateTime?"
|
||||
}
|
||||
],
|
||||
"foreignKeys": [],
|
||||
"indexes": [
|
||||
{
|
||||
"__className__": "serverpod.IndexDefinition",
|
||||
"indexName": "account_deletion_notice_idx",
|
||||
"elements": [
|
||||
{
|
||||
"__className__": "serverpod.IndexElementDefinition",
|
||||
"type": 0,
|
||||
"definition": "account"
|
||||
},
|
||||
{
|
||||
"__className__": "serverpod.IndexElementDefinition",
|
||||
"type": 0,
|
||||
"definition": "member"
|
||||
}
|
||||
],
|
||||
"type": "btree",
|
||||
"isUnique": true,
|
||||
"isPrimary": false
|
||||
}
|
||||
],
|
||||
"managed": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"warnings": [],
|
||||
"migrationApiVersion": 1
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
BEGIN;
|
||||
|
||||
--
|
||||
-- ACTION CREATE TABLE
|
||||
--
|
||||
CREATE TABLE "account_deletion_notice" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"account" uuid NOT NULL,
|
||||
"member" text NOT NULL,
|
||||
"createdAt" timestamp without time zone NOT NULL,
|
||||
"attempts" bigint NOT NULL,
|
||||
"lastAttemptAt" timestamp without time zone
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "account_deletion_notice_idx" ON "account_deletion_notice" USING btree ("account", "member");
|
||||
|
||||
|
||||
--
|
||||
-- MIGRATION VERSION FOR halkyon_todo
|
||||
--
|
||||
INSERT INTO "serverpod_migrations" ("module", "version", "timestamp")
|
||||
VALUES ('halkyon_todo', '20261019204122341-deletion-notices', now())
|
||||
ON CONFLICT ("module")
|
||||
DO UPDATE SET "version" = '20261019204122341-deletion-notices', "timestamp" = now();
|
||||
|
||||
--
|
||||
-- MIGRATION VERSION FOR halkyon_base
|
||||
--
|
||||
INSERT INTO "serverpod_migrations" ("module", "version", "timestamp")
|
||||
VALUES ('halkyon_base', '20261019202835333-deletion-notices', now())
|
||||
ON CONFLICT ("module")
|
||||
DO UPDATE SET "version" = '20261019202835333-deletion-notices', "timestamp" = now();
|
||||
|
||||
--
|
||||
-- MIGRATION VERSION FOR serverpod
|
||||
--
|
||||
INSERT INTO "serverpod_migrations" ("module", "version", "timestamp")
|
||||
VALUES ('serverpod', '20260824182259319', now())
|
||||
ON CONFLICT ("module")
|
||||
DO UPDATE SET "version" = '20260824182259319', "timestamp" = now();
|
||||
|
||||
--
|
||||
-- MIGRATION VERSION FOR serverpod_auth_idp
|
||||
--
|
||||
INSERT INTO "serverpod_migrations" ("module", "version", "timestamp")
|
||||
VALUES ('serverpod_auth_idp', '20260924105404509', now())
|
||||
ON CONFLICT ("module")
|
||||
DO UPDATE SET "version" = '20260924105404509', "timestamp" = now();
|
||||
|
||||
--
|
||||
-- MIGRATION VERSION FOR serverpod_auth_core
|
||||
--
|
||||
INSERT INTO "serverpod_migrations" ("module", "version", "timestamp")
|
||||
VALUES ('serverpod_auth_core', '20260924105232991', now())
|
||||
ON CONFLICT ("module")
|
||||
DO UPDATE SET "version" = '20260924105232991', "timestamp" = now();
|
||||
|
||||
|
||||
COMMIT;
|
||||
|
|
@ -6,3 +6,4 @@
|
|||
|
||||
20261019193547604
|
||||
20261019201213254-profiles
|
||||
20261019204122341-deletion-notices
|
||||
|
|
|
|||
|
|
@ -195,4 +195,34 @@ class _PruningFutureCall {
|
|||
await _localUniqueSession.close();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> tellMembersOfDeletions(
|
||||
_ist.TestSessionBuilder sessionBuilder,
|
||||
) async {
|
||||
var _localUniqueSession =
|
||||
(sessionBuilder as _ist.InternalTestSessionBuilder).internalBuild();
|
||||
try {
|
||||
await _i772x17y.PruningTellMembersOfDeletionsFutureCall().invoke(
|
||||
_localUniqueSession,
|
||||
null,
|
||||
);
|
||||
} finally {
|
||||
await _localUniqueSession.close();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> forgetDeletedAccounts(
|
||||
_ist.TestSessionBuilder sessionBuilder,
|
||||
) async {
|
||||
var _localUniqueSession =
|
||||
(sessionBuilder as _ist.InternalTestSessionBuilder).internalBuild();
|
||||
try {
|
||||
await _i772x17y.PruningForgetDeletedAccountsFutureCall().invoke(
|
||||
_localUniqueSession,
|
||||
null,
|
||||
);
|
||||
} finally {
|
||||
await _localUniqueSession.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import 'package:halkyon_base_server/base.dart';
|
||||
import 'package:halkyon_todo_server/src/pruning.dart';
|
||||
import 'package:halkyon_todo_server/src/todo_base.dart';
|
||||
import 'package:serverpod/protocol.dart' show FutureCallEntry;
|
||||
import 'package:serverpod/serverpod.dart';
|
||||
import 'package:serverpod_auth_idp_server/core.dart';
|
||||
|
|
@ -64,6 +65,26 @@ void main() {
|
|||
expect(person.id, success.authUserId);
|
||||
});
|
||||
|
||||
test("is a member of the instance's register the operator names, and "
|
||||
'holds the register otherwise (ADR 0016)', () {
|
||||
expect(
|
||||
todoBase(
|
||||
accounts: AccountsMode.fromEnvironment(const {
|
||||
'ACCOUNT_REGISTER_URL': 'http://learn:8082',
|
||||
}),
|
||||
).accounts,
|
||||
isA<MemberOfRegister>().having(
|
||||
(member) => member.register,
|
||||
'register',
|
||||
Uri.parse('http://learn:8082'),
|
||||
),
|
||||
);
|
||||
expect(
|
||||
todoBase(accounts: AccountsMode.fromEnvironment(const {})).accounts,
|
||||
isA<HoldsRegister>(),
|
||||
);
|
||||
});
|
||||
|
||||
test(
|
||||
'the pruning is scheduled once, however often the server starts',
|
||||
() async {
|
||||
|
|
|
|||
Loading…
Reference in a new issue