The best way to control Claude Code, Codex and more from any computer or phone

main
ts 152 lines 4.86 KB
Raw
1 import type { MigrationsInput } from "@alchemy.run/sql/Migrations";
2
3 /**
4 * Region selector for a PlanetScale Database.
5 */
6 export interface DatabaseRegion {
7 /**
8 * Region slug (e.g. `"us-east"`, `"eu-west"`, `"gcp-us-central1"`).
9 * @see https://planetscale.com/docs/concepts/regions#available-regions
10 */
11 slug: "us-east" | "eu-west" | "gcp-us-central1" | (string & {});
12 }
13
14 /**
15 * Properties shared between {@link MySQLDatabase} and
16 * {@link PostgresDatabase}. Engine-specific props live on the per-engine
17 * resource types.
18 */
19 export interface BaseDatabaseProps {
20 /**
21 * Database name. Must be lowercase. If omitted, a unique name will be
22 * generated from the stack/stage/logical-id. A change that replaces the
23 * database needs a new name, so it fails while an explicit name stays
24 * the same.
25 */
26 name?: string;
27
28 /**
29 * Region where the database will be created. Cannot be changed after
30 * creation. If omitted, the organization's default region is used.
31 */
32 region?: DatabaseRegion;
33
34 /**
35 * Number of replicas for the database. `0` for non-HA, `2+` for HA.
36 * Create-only for PostgreSQL databases; MySQL databases reconcile
37 * changes in place ({@link MySQLDatabaseProps.replicas}).
38 */
39 replicas?: number;
40
41 /**
42 * Whether deploy requests must be approved by a database administrator
43 * other than the request creator.
44 */
45 requireApprovalForDeploy?: boolean;
46
47 /**
48 * Whether to limit branch creation to the same region as the one
49 * selected during database creation.
50 */
51 restrictBranchRegion?: boolean;
52
53 /**
54 * Whether the web console can be used on the production branch.
55 */
56 productionBranchWebConsole?: boolean;
57
58 /**
59 * Whether PlanetScale refuses to delete the database. While enabled,
60 * destroying or replacing the database fails with a
61 * `PlanetscaleDeletionProtected` error; set it to `false` and deploy
62 * before deleting. If omitted, Alchemy leaves the database's current
63 * setting unchanged.
64 *
65 * A replacement (e.g. a region change) creates the new database first,
66 * so deleting the protected old one fails afterwards. The resource then
67 * manages the new database, so turn protection off on the old one in
68 * PlanetScale directly and deploy again.
69 */
70 deletionProtection?: boolean;
71
72 /**
73 * The default branch of the database.
74 * @default "main"
75 */
76 defaultBranch?: string;
77
78 /**
79 * SQL migrations to apply against the default branch. Accepts a directory
80 * path, a `Drizzle.Schema` resource, or `{ dir, table? }`.
81 *
82 * Bookkeeping always lives in Alchemy's `__alchemy_migrations` table. A
83 * database previously migrated by drizzle-kit or Prisma is adopted by a
84 * one-way conversion on first deploy: the old tool's applied history is
85 * copied into Alchemy's table and the old table is left frozen. No
86 * baselining required.
87 */
88 migrations?: MigrationsInput;
89
90 /**
91 * Paths to additional `.sql` files to apply after migrations. Each file is
92 * hashed; only files whose contents change are re-applied on later deploys.
93 */
94 importFiles?: string[];
95 }
96
97 /**
98 * Output attributes shared by both database engines.
99 */
100 export interface BaseDatabaseAttributes {
101 /** The unique identifier of the database. */
102 id: string;
103 /** The name of the database. */
104 name: string;
105 /** The PlanetScale organization slug that owns the database. */
106 organization: string;
107 /** The current state of the database. */
108 state: string;
109 /** The default branch name. */
110 defaultBranch: string;
111 /** The plan tier (e.g. `"hobby"`, `"scaler"`). */
112 plan: string;
113 /** Time at which the database was created (ISO 8601). */
114 createdAt: string;
115 /** Time at which the database was last updated (ISO 8601). */
116 updatedAt: string;
117 /** HTML URL for accessing the database in the dashboard. */
118 htmlUrl: string;
119 /** The region of the database as reported by PlanetScale. */
120 region: DatabaseRegion;
121 /** The cluster size that was actually applied. */
122 clusterSize: string;
123 /** Directory containing migration files, if configured. */
124 migrationsDir: string | undefined;
125 /** Table used to track applied migrations, if configured. */
126 migrationsTable: string | undefined;
127 /** Content hashes for the last applied migration files. */
128 migrationsHashes: Record<string, string>;
129 /** Content hashes for the last applied import files. */
130 importHashes: Record<string, string>;
131 /**
132 * Whether deploy requests must be approved by a database administrator
133 * other than the request creator.
134 */
135 requireApprovalForDeploy: boolean;
136
137 /**
138 * Whether to limit branch creation to the same region as the one
139 * selected during database creation.
140 */
141 restrictBranchRegion: boolean;
142
143 /**
144 * Whether the web console can be used on the production branch.
145 */
146 productionBranchWebConsole: boolean;
147
148 /**
149 * Whether deletion protection is enabled for the database.
150 */
151 deletionProtection: boolean;
152 }