Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,19 @@ pnpm -C packages/backend db:migrate:dev
# for production, run `pnpm -C packages/backend db:migrate:prod`
```

### Bootstrap the first platform admin

Spinupmail does not auto-promote the first user and does not use env-based admin
IDs. After migrations have added the Better Auth admin fields, promote the first
admin directly in D1:

```bash
pnpm -C packages/backend exec wrangler d1 execute SUM_DB --local --command "UPDATE users SET role = 'admin' WHERE email = 'you@example.com';"
```

For production, run the same statement with `--remote` after confirming the
target user has signed up and verified their email.

## 5. Deploy the Backend Worker

```bash
Expand Down
28 changes: 28 additions & 0 deletions packages/backend/drizzle/0011_wet_sleeper.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
CREATE TABLE `operational_events` (
`id` text PRIMARY KEY NOT NULL,
`severity` text NOT NULL,
`type` text NOT NULL,
`organization_id` text,
`address_id` text,
`email_id` text,
`integration_id` text,
`dispatch_id` text,
`message` text NOT NULL,
`metadata_json` text,
`created_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL,
FOREIGN KEY (`organization_id`) REFERENCES `organizations`(`id`) ON UPDATE no action ON DELETE set null,
FOREIGN KEY (`address_id`) REFERENCES `email_addresses`(`id`) ON UPDATE no action ON DELETE set null,
FOREIGN KEY (`email_id`) REFERENCES `emails`(`id`) ON UPDATE no action ON DELETE set null,
FOREIGN KEY (`integration_id`) REFERENCES `organization_integrations`(`id`) ON UPDATE no action ON DELETE set null,
FOREIGN KEY (`dispatch_id`) REFERENCES `integration_dispatches`(`id`) ON UPDATE no action ON DELETE set null
);
--> statement-breakpoint
CREATE INDEX `operational_events_created_idx` ON `operational_events` (`created_at`);--> statement-breakpoint
CREATE INDEX `operational_events_severity_created_idx` ON `operational_events` (`severity`,`created_at`);--> statement-breakpoint
CREATE INDEX `operational_events_type_created_idx` ON `operational_events` (`type`,`created_at`);--> statement-breakpoint
CREATE INDEX `operational_events_org_created_idx` ON `operational_events` (`organization_id`,`created_at`);--> statement-breakpoint
ALTER TABLE `sessions` ADD `impersonated_by` text;--> statement-breakpoint
ALTER TABLE `users` ADD `role` text;--> statement-breakpoint
ALTER TABLE `users` ADD `banned` integer DEFAULT false;--> statement-breakpoint
ALTER TABLE `users` ADD `ban_reason` text;--> statement-breakpoint
ALTER TABLE `users` ADD `ban_expires` integer;
Loading
Loading