@getxflow/cli 0.28.0 → 0.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/api.js CHANGED
@@ -16,7 +16,9 @@ class ApiError extends Error {
16
16
  limit;
17
17
  removing;
18
18
  request;
19
- constructor(message, code, status, hint, details = {}) {
19
+ /** The platform that answered: its signed-in organizations are the ones worth naming. */
20
+ apiUrl;
21
+ constructor(message, code, status, hint, details = {}, apiUrl) {
20
22
  super(message);
21
23
  this.name = 'ApiError';
22
24
  this.code = code;
@@ -26,6 +28,7 @@ class ApiError extends Error {
26
28
  this.limit = details.limit;
27
29
  this.removing = details.removing;
28
30
  this.request = details.request;
31
+ this.apiUrl = apiUrl;
29
32
  }
30
33
  }
31
34
  exports.ApiError = ApiError;
@@ -126,7 +129,7 @@ async function readError(response, client) {
126
129
  const text = await response.text().catch(() => '');
127
130
  try {
128
131
  const parsed = JSON.parse(text);
129
- return new ApiError(parsed.error || `Request rejected (${response.status})`, parsed.code || 'unknown', response.status, parsed.hint, parsed);
132
+ return new ApiError(parsed.error || `Request rejected (${response.status})`, parsed.code || 'unknown', response.status, parsed.hint, parsed, client.apiUrl);
130
133
  }
131
134
  catch {
132
135
  return notAnAnswer(response.status, client.apiUrl, text);
package/dist/bin.js CHANGED
@@ -176,11 +176,15 @@ async function run(args) {
176
176
  await (0, db_1.dbQuery)({ ...args, words: args.words.slice(2) });
177
177
  return;
178
178
  }
179
+ if (second === 'move') {
180
+ await (0, db_1.dbMove)(rest);
181
+ return;
182
+ }
179
183
  if (second === undefined || second === 'status') {
180
184
  await (0, db_1.dbStatus)({ ...args, words: args.words.slice(2) });
181
185
  return;
182
186
  }
183
- throw new errors_1.CliError(`Unknown command: db ${second}`, 'Available: status, list, schema, query and migrate');
187
+ throw new errors_1.CliError(`Unknown command: db ${second}`, 'Available: status, list, schema, query, migrate and move');
184
188
  case 'storage':
185
189
  if (second === 'push') {
186
190
  await (0, storage_1.storagePush)(rest);
@@ -327,7 +331,7 @@ async function main() {
327
331
  if (process.env.XFLOW_TOKEN?.trim()) {
328
332
  (0, ui_1.fatalNote)((0, ui_1.dim)(' XFLOW_TOKEN is set: it is the key of one organization and is used as it comes, so a project or a page of another one is not found'));
329
333
  }
330
- else if ((0, credentials_1.anyMultipleOrgs)()) {
334
+ else if (e.apiUrl && (0, credentials_1.listOrgs)(e.apiUrl).length > 1) {
331
335
  (0, ui_1.fatalNote)((0, ui_1.dim)(' Several organizations are signed in: the answer may live in another one, see xflow org'));
332
336
  }
333
337
  }
@@ -4,6 +4,7 @@ exports.dbStatus = dbStatus;
4
4
  exports.dbList = dbList;
5
5
  exports.dbSchema = dbSchema;
6
6
  exports.dbQuery = dbQuery;
7
+ exports.dbMove = dbMove;
7
8
  exports.dbMigrate = dbMigrate;
8
9
  const node_fs_1 = require("node:fs");
9
10
  const node_crypto_1 = require("node:crypto");
@@ -24,12 +25,34 @@ function serverLabel(server) {
24
25
  return 'platform';
25
26
  return server.status === 'active' ? `own "${server.name}"` : `own "${server.name}", ${server.status}`;
26
27
  }
27
- function printPlace(history) {
28
+ const moving = (move) => move?.status === 'copying' || move?.status === 'switching';
29
+ /** Asked apart from the history: during a move the database does not answer, this does. */
30
+ async function projectDatabase(client, projectId) {
31
+ try {
32
+ return await (0, api_1.apiJson)(client, `/api/v1/projects/${projectId}/db/move`);
33
+ }
34
+ catch (e) {
35
+ if (e instanceof api_1.ApiError && e.code === 'not_deployed')
36
+ return null;
37
+ throw e;
38
+ }
39
+ }
40
+ function printPlace(history, place) {
28
41
  (0, ui_1.out)(`Schema: ${(0, ui_1.bold)(history.schema)}`);
29
42
  if (history.server !== undefined)
30
43
  (0, ui_1.out)(`Server: ${serverLabel(history.server)}`);
44
+ if (place?.move)
45
+ (0, ui_1.out)(`Move: ${moveLine(place.move)}`);
31
46
  (0, ui_1.out)('');
32
47
  }
48
+ /** Mid-move the history cannot be read, so the answer is the move itself. */
49
+ function printMoving(place) {
50
+ if (place.database)
51
+ (0, ui_1.out)(`Database: ${(0, ui_1.bold)(place.database.name)}`);
52
+ (0, ui_1.out)(`Server: ${serverLabel(place.server)}`);
53
+ (0, ui_1.out)(`Move: ${place.move?.note ?? ''}`);
54
+ (0, ui_1.note)((0, ui_1.dim)(' Migrations and queries wait until it is over; the platform finishes it on its own'));
55
+ }
33
56
  function checksum(sql) {
34
57
  return (0, node_crypto_1.createHash)('sha256').update(sql).digest('hex').slice(0, 16);
35
58
  }
@@ -58,8 +81,11 @@ async function dbStatus(args) {
58
81
  // is the applied history alone, which does not depend on any working copy.
59
82
  if ((0, args_1.flagString)(args, 'project') !== undefined) {
60
83
  const { projectId, client } = await (0, session_1.projectTarget)(args);
84
+ const place = await projectDatabase(client, projectId);
85
+ if (place && moving(place.move))
86
+ return printMoving(place);
61
87
  const history = await (0, api_1.apiJson)(client, `/api/v1/projects/${projectId}/db/migrate`);
62
- printPlace(history);
88
+ printPlace(history, place);
63
89
  if (history.applied.length === 0) {
64
90
  (0, ui_1.note)('No migrations have been applied yet');
65
91
  return;
@@ -71,9 +97,12 @@ async function dbStatus(args) {
71
97
  const { root, config } = (0, config_1.requireProject)();
72
98
  const client = await (0, session_1.connectProject)(config.projectId, root, config);
73
99
  const local = readMigrations(root);
100
+ const place = await projectDatabase(client, config.projectId);
101
+ if (place && moving(place.move))
102
+ return printMoving(place);
74
103
  const history = await (0, api_1.apiJson)(client, `/api/v1/projects/${config.projectId}/db/migrate`);
75
104
  const applied = new Map(history.applied.map((row) => [row.name, row]));
76
- printPlace(history);
105
+ printPlace(history, place);
77
106
  if (local.length === 0 && applied.size === 0) {
78
107
  (0, ui_1.note)(`No migrations. The first one: ${MIGRATIONS_DIR}/0001_init.sql`);
79
108
  return;
@@ -104,6 +133,19 @@ async function dbStatus(args) {
104
133
  (0, ui_1.warn)('A changed file will not be applied again: write a new migration');
105
134
  }
106
135
  }
136
+ function serverRow(server) {
137
+ const room = server.used_bytes !== null && server.space_bytes !== null
138
+ ? `${(0, ui_1.formatBytes)(server.used_bytes)} of ${(0, ui_1.formatBytes)(server.space_bytes)} used`
139
+ : '';
140
+ return [
141
+ server.id === null ? 'platform' : `own "${server.name}"`,
142
+ server.id === null ? 'plan space' : server.tier ?? '',
143
+ server.status === 'active' ? '' : server.status,
144
+ room,
145
+ `${server.databases} ${server.databases === 1 ? 'database' : 'databases'}`,
146
+ server.new_databases_here ? 'new databases go here' : '',
147
+ ];
148
+ }
107
149
  function attachedProjects(database) {
108
150
  const names = database.projects.map((project) => project.name);
109
151
  if (database.hidden_projects > 0)
@@ -123,24 +165,34 @@ async function dbList() {
123
165
  if (data.databases.length === 0) {
124
166
  (0, ui_1.note)('The organization has no databases');
125
167
  (0, ui_1.note)((0, ui_1.dim)(' One is created with the first project: xflow init'));
126
- return;
127
168
  }
128
- (0, ui_1.table)(data.databases.map((database) => [
169
+ else {
170
+ printDatabases(data.databases, data.total, data.truncated);
171
+ }
172
+ printServers(data.servers);
173
+ }
174
+ function moveLine(move) {
175
+ return move.finished_at ? `${move.note} (${(0, ui_1.formatAge)(move.finished_at)})` : move.note;
176
+ }
177
+ function printDatabases(databases, total, truncated) {
178
+ (0, ui_1.table)(databases.map((database) => [
129
179
  database.name,
130
180
  database.id,
131
181
  database.schema ?? '-',
132
182
  serverLabel(database.server),
133
183
  attachedProjects(database),
134
184
  ]));
135
- if (data.truncated)
136
- (0, ui_1.note)((0, ui_1.dim)(` Shown ${data.databases.length} of ${data.total}`));
137
- for (const database of data.databases) {
185
+ if (truncated)
186
+ (0, ui_1.note)((0, ui_1.dim)(` Shown ${databases.length} of ${total}`));
187
+ for (const database of databases) {
138
188
  const attached = database.projects.length + database.hidden_projects;
139
189
  if (attached > 1)
140
190
  (0, ui_1.note)((0, ui_1.dim)(` ${database.name} is shared by ${attached} projects: a migration affects all of them`));
191
+ if (database.move)
192
+ (0, ui_1.note)((0, ui_1.dim)(` ${database.name}: ${moveLine(database.move)}`));
141
193
  }
142
194
  const down = new Map();
143
- for (const { server } of data.databases)
195
+ for (const { server } of databases)
144
196
  if (server && server.status !== 'active')
145
197
  down.set(server.id, server);
146
198
  for (const server of down.values()) {
@@ -148,6 +200,15 @@ async function dbList() {
148
200
  'Not fixable from the code: tell the person, the server state is in the "Data" section of the web interface'));
149
201
  }
150
202
  }
203
+ /** Where a new or a moved database can go, with the room on each. Only the platform: no choice to show. */
204
+ function printServers(servers) {
205
+ if (!servers || servers.length < 2)
206
+ return;
207
+ (0, ui_1.out)('');
208
+ (0, ui_1.out)((0, ui_1.bold)('Servers'));
209
+ (0, ui_1.table)(servers.map(serverRow));
210
+ (0, ui_1.note)((0, ui_1.dim)(' A new project with its database on one of them: xflow init --server <name>. An existing one: xflow db move --to <name>'));
211
+ }
151
212
  /** Long values would tear the columns apart; the cut is marked, never silent. */
152
213
  const CELL_LIMIT = 60;
153
214
  function plain(value) {
@@ -255,6 +316,62 @@ async function dbQuery(args) {
255
316
  : ` Shown the first ${data.rows.length} rows, more exist: narrow the query, with a where clause or an offset`));
256
317
  }
257
318
  }
319
+ const MOVE_POLL_MS = 3_000;
320
+ /** Past this the command lets go: the move carries on, db status follows it. */
321
+ const MOVE_FOLLOW_MS = 10 * 60_000;
322
+ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
323
+ /**
324
+ * Moving the project database to another server of the organization. The platform
325
+ * runs the move by itself; this command starts it and follows it to the end.
326
+ */
327
+ async function dbMove(args) {
328
+ const to = (0, args_1.flagString)(args, 'to');
329
+ if (!to) {
330
+ throw new errors_1.CliError('Name the server: --to <name>', 'The servers and their names: xflow db list ("platform" is the common one)');
331
+ }
332
+ const { projectId, client } = await (0, session_1.projectTarget)(args);
333
+ const path = `/api/v1/projects/${projectId}/db/move`;
334
+ let place;
335
+ try {
336
+ place = await (0, api_1.apiJson)(client, path, {
337
+ method: 'POST',
338
+ body: { to, confirm: (0, args_1.flagString)(args, 'confirm') },
339
+ timeoutMs: 60_000,
340
+ });
341
+ }
342
+ catch (e) {
343
+ // Said in the words of this command: the flag, and the name that goes in it.
344
+ if (e instanceof api_1.ApiError && e.code === 'confirm_required') {
345
+ const found = await projectDatabase(client, projectId).catch(() => null);
346
+ const name = found?.database?.name ?? '<database>';
347
+ throw new errors_1.CliError(e.message, `To move it: xflow db move --to "${to}" --confirm "${name}"`);
348
+ }
349
+ throw e;
350
+ }
351
+ (0, ui_1.note)((0, ui_1.dim)(' The platform carries the move through by itself: stopping this command does not stop it'));
352
+ const deadline = Date.now() + MOVE_FOLLOW_MS;
353
+ let shown = '';
354
+ while (moving(place.move)) {
355
+ const line = place.move?.note ?? '';
356
+ if (line !== shown)
357
+ (0, ui_1.step)(line);
358
+ shown = line;
359
+ if (Date.now() > deadline) {
360
+ (0, ui_1.note)('Still going: xflow db status follows it');
361
+ return;
362
+ }
363
+ await sleep(MOVE_POLL_MS);
364
+ place = await (0, api_1.apiJson)(client, path);
365
+ }
366
+ const { move } = place;
367
+ if (move?.status === 'failed')
368
+ throw new errors_1.CliError(move.note);
369
+ if (move && (move.functions_done ?? 0) < (move.functions_total ?? 0)) {
370
+ (0, ui_1.warn)(move.note);
371
+ return;
372
+ }
373
+ (0, ui_1.ok)(move?.note ?? `The database is on ${serverLabel(place.server)}`);
374
+ }
258
375
  async function dbMigrate(args) {
259
376
  const { root, config } = (0, config_1.requireProject)();
260
377
  const client = await (0, session_1.connectProject)(config.projectId, root, config);
@@ -69,7 +69,8 @@ async function init(args) {
69
69
  (0, ui_1.step)('Creating the project on the platform');
70
70
  const project = await (0, api_1.apiJson)(client, '/api/v1/projects', {
71
71
  method: 'POST',
72
- body: { name, database_id: (0, args_1.flagString)(args, 'database') ?? null },
72
+ body: { name, database_id: (0, args_1.flagString)(args, 'database') ?? null, server: (0, args_1.flagString)(args, 'server') ?? null },
73
+ timeoutMs: 60_000,
73
74
  });
74
75
  try {
75
76
  (0, node_fs_1.mkdirSync)(target, { recursive: true });
@@ -94,6 +95,10 @@ async function init(args) {
94
95
  }
95
96
  (0, skills_1.installSkillQuietly)(target);
96
97
  (0, ui_1.ok)(`Project "${project.name}" created: ${files.length} template files`);
98
+ if (project.database) {
99
+ const { server } = project.database;
100
+ (0, ui_1.note)((0, ui_1.dim)(` Its database "${project.database.name}" is on ${server ? `own "${server.name}"` : 'the platform server'}`));
101
+ }
97
102
  (0, ui_1.out)('');
98
103
  (0, ui_1.out)(` ${(0, ui_1.bold)('Next:')}`);
99
104
  (0, ui_1.out)(` cd ${(0, node_path_1.basename)(target)}`);
@@ -7,7 +7,6 @@ exports.rememberOrgName = rememberOrgName;
7
7
  exports.setActiveOrg = setActiveOrg;
8
8
  exports.forgetOrg = forgetOrg;
9
9
  exports.forgetAllOrgs = forgetAllOrgs;
10
- exports.anyMultipleOrgs = anyMultipleOrgs;
11
10
  exports.pickKey = pickKey;
12
11
  exports.storedKeyInputs = storedKeyInputs;
13
12
  const node_fs_1 = require("node:fs");
@@ -198,11 +197,6 @@ function forgetAllOrgs(apiUrl) {
198
197
  writeStore(store);
199
198
  return true;
200
199
  }
201
- /** True when any address holds keys of more than one organization. */
202
- function anyMultipleOrgs() {
203
- const store = readStore();
204
- return Object.values(store.orgs ?? {}).some((address) => Object.keys(address.keys).length > 1);
205
- }
206
200
  /**
207
201
  * One rule for the whole CLI: XFLOW_TOKEN (default address only) beats the
208
202
  * folder's organization, which beats the active one. A folder bound to an
package/dist/flags.js CHANGED
@@ -40,7 +40,7 @@ exports.KNOWN = {
40
40
  'org members': [],
41
41
  'org switch': [],
42
42
  templates: [],
43
- init: ['name', 'template', 'database'],
43
+ init: ['name', 'template', 'database', 'server'],
44
44
  link: [],
45
45
  projects: [],
46
46
  'projects list': [],
@@ -75,6 +75,7 @@ exports.KNOWN = {
75
75
  'db schema': ['project'],
76
76
  'db query': ['limit', 'json', 'project'],
77
77
  'db migrate': ['dry-run', 'allow-destructive'],
78
+ 'db move': ['to', 'confirm', 'project'],
78
79
  storage: ['json', 'project'],
79
80
  'storage ls': ['json', 'project'],
80
81
  'storage list': ['json', 'project'],
package/dist/help.js CHANGED
@@ -88,6 +88,8 @@ ${(0, ui_1.bold)('Database')}
88
88
  xflow db query "select ..." read data, in a read-only transaction
89
89
  xflow db migrate [--dry-run] [--allow-destructive]
90
90
  apply the migrations from migrations/*.sql
91
+ xflow db move --to <server> --confirm <database>
92
+ move the project database to another server
91
93
 
92
94
  ${(0, ui_1.bold)('Pages')}
93
95
  xflow pages public sites of the organization at <name>.xflowpage.ru
@@ -162,7 +164,7 @@ no working copy of its own:
162
164
  xflow db query --project 3f2a… "select id, title from tasks where done = false"
163
165
  xflow functions invoke kanban --project 3f2a… --data-file card.json
164
166
 
165
- Which commands: ${(0, ui_1.bold)('db status')}, ${(0, ui_1.bold)('db query')}, ${(0, ui_1.bold)('db schema')}, ${(0, ui_1.bold)('functions list')},
167
+ Which commands: ${(0, ui_1.bold)('db status')}, ${(0, ui_1.bold)('db query')}, ${(0, ui_1.bold)('db schema')}, ${(0, ui_1.bold)('db move')}, ${(0, ui_1.bold)('functions list')},
166
168
  ${(0, ui_1.bold)('functions invoke')}, ${(0, ui_1.bold)('functions logs')}, ${(0, ui_1.bold)('logs')}, ${(0, ui_1.bold)('env')}, ${(0, ui_1.bold)('env rm')},
167
169
  ${(0, ui_1.bold)('connections')}, ${(0, ui_1.bold)('connections link')}, ${(0, ui_1.bold)('connections unlink')}, ${(0, ui_1.bold)('schedules')},
168
170
  ${(0, ui_1.bold)('schedules set')}, ${(0, ui_1.bold)('schedules rm')}, ${(0, ui_1.bold)('storage ls')}, ${(0, ui_1.bold)('storage push')},
@@ -295,13 +297,29 @@ will work.`,
295
297
  --json prints the values whole)
296
298
  xflow db query <file>.sql the same, the query read from a file
297
299
  xflow db migrate apply migrations/*.sql
300
+ xflow db move --to <server> --confirm <database>
301
+ move the project database to another server
298
302
 
299
303
  ${(0, ui_1.bold)('list')} is about the organization, not about this project: it names the logical
300
304
  databases, the identifier ${(0, ui_1.bold)('xflow init --database <id>')} asks for, and the projects
301
305
  attached to each one. That last column is the one to read before a migration. The server
302
306
  column says where a database lives: ${(0, ui_1.bold)('platform')} is the common one, ${(0, ui_1.bold)('own "<name>"')} the
303
307
  organization's own server. While an own server is not running, its databases do not
304
- answer, and that is not fixable from the code: its state is in the web interface.
308
+ answer, and that is not fixable from the code: its state is in the web interface. An
309
+ organization with own servers also gets them listed, with the room used on each and the
310
+ one new databases go to: that is the choice for ${(0, ui_1.bold)('xflow init --server')} and ${(0, ui_1.bold)('db move')}.
311
+
312
+ ${(0, ui_1.bold)('move')} takes the database of this project to another server of the organization:
313
+ ${(0, ui_1.bold)('platform')} or an own server by name (or id, when two share a name). The platform copies
314
+ the tables, switches the functions of every project on the database and removes the old
315
+ copy; nothing needs a deploy. While it copies, the applications read data but cannot save
316
+ anything new, usually for a couple of minutes, and that goes for every project on the
317
+ database, which is why ${(0, ui_1.bold)('--confirm')} takes the database name. It also needs the right
318
+ to move databases on the key: off by default, only its owner turns it on, in the platform
319
+ settings where the key permissions live. The command follows the move to the end;
320
+ stopping it does not stop the move, and ${(0, ui_1.bold)('xflow db status')} shows where it stands. A move
321
+ that fails is rolled back: the database stays where it was and works as before. Buying,
322
+ paying for and deleting servers stay with the person, in the web interface.
305
323
 
306
324
  ${(0, ui_1.bold)('schema')} answers a different question than the ${(0, ui_1.bold)('migrations/')} directory: one logical
307
325
  database is shared by several projects, so the files say what you did, and the schema
@@ -700,6 +718,12 @@ is not a formality: your own palette on top of them looks foreign inside the pla
700
718
  --name <name> project name (the folder name by default)
701
719
  --template <id> a different template (the list: xflow templates)
702
720
  --database <id> attach a logical database of the organization (the list: xflow db list)
721
+ --server <name> a new database for the project, right away on that server:
722
+ platform, or an own server of the organization (xflow db list)
723
+
724
+ Without either flag the project gets its database with the first migration, on the
725
+ server new databases of the organization go to. ${(0, ui_1.bold)('--server')} decides it up front: the
726
+ server has to be running, and the database counts against the plan at once.
703
727
 
704
728
  The order: the project is created on the platform first, because without it there is
705
729
  nowhere to get the token for .env. If writing the files fails, the project stays empty
package/dist/ui.js CHANGED
@@ -96,7 +96,9 @@ function formatBytes(bytes) {
96
96
  return `${bytes} B`;
97
97
  if (bytes < 1024 * 1024)
98
98
  return `${(bytes / 1024).toFixed(1)} KB`;
99
- return `${(bytes / 1024 / 1024).toFixed(1)} MB`;
99
+ if (bytes < 1024 * 1024 * 1024)
100
+ return `${(bytes / 1024 / 1024).toFixed(1)} MB`;
101
+ return `${(bytes / 1024 / 1024 / 1024).toFixed(1)} GB`;
100
102
  }
101
103
  function formatAge(iso) {
102
104
  if (!iso)
package/dist/version.js CHANGED
@@ -2,6 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DEFAULT_API_URL = exports.CLI_VERSION = void 0;
4
4
  /** Keep in sync with cli/package.json. */
5
- exports.CLI_VERSION = '0.28.0';
5
+ exports.CLI_VERSION = '0.29.0';
6
6
  /** Overridden by XFLOW_API_URL or the `api` field in xflow.json. */
7
7
  exports.DEFAULT_API_URL = 'https://app.getxflow.com';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getxflow/cli",
3
- "version": "0.28.0",
3
+ "version": "0.29.0",
4
4
  "description": "CLI for the XFlow platform: source sync, deployment and publishing of applications",
5
5
  "license": "UNLICENSED",
6
6
  "engines": {
@@ -22,7 +22,7 @@ contains the fix.
22
22
 
23
23
  ## Keeping these instructions current
24
24
 
25
- These instructions ship with xflow CLI 0.28.0, so the copy you are reading can be older than
25
+ These instructions ship with xflow CLI 0.29.0, so the copy you are reading can be older than
26
26
  the CLI answering your commands.
27
27
 
28
28
  When the CLI says this file does not match it, run `xflow skills --refresh` and then **read
@@ -435,13 +435,24 @@ transaction (50 rows by default, `--limit` up to 300; `--json` prints long value
435
435
  with double quotes goes in a `.sql` file outside the project, `xflow db query ../q.sql`: PowerShell
436
436
  strips them from arguments. Look before you write a migration against a shared database.
437
437
 
438
- An organization can have its own database server, and its new databases are then created there.
439
- `xflow db list` names the server of each database (`platform` is the common one), `xflow db
440
- status` the one under this project. Code stays the same: `DATABASE_URL` arrives as before, pass it
441
- as is, without an `ssl` option (an own server is reached over a closed network, and `ssl` makes
442
- the connection fail). While an own server is not running, migrations and queries say so and
443
- functions that use the database time out. That is not your code and not yours to fix: tell the
444
- person, who sees the server state in the "Data" section of the web interface, instead of retrying.
438
+ An organization can have own database servers, several of them for different jobs. `xflow db
439
+ list` names the server of each database (`platform` is the common one) and lists the own servers
440
+ with the room used and the one new databases go to; `xflow db status` names the one under this
441
+ project. The server belongs to the database: projects sharing a database share its server.
442
+ - A new project with its database on a chosen server: `xflow init --server <name>` (`platform`
443
+ for the common one). Without it the first migration creates the database where new ones go.
444
+ - An existing database: `xflow db move --to <name> --confirm <database name>`. Writes to every
445
+ project on it close while it copies, usually a couple of minutes; the platform switches the
446
+ functions itself, no deploy. It needs the right to move databases, off on the key by default:
447
+ refused for the right, say what should move where and why, and the person turns it on or
448
+ moves it in the "Data" section.
449
+ - Buying, paying for and deleting servers are the person's, in the web interface.
450
+
451
+ Code stays the same: `DATABASE_URL` arrives as before, pass it as is, without an `ssl` option (an
452
+ own server is reached over a closed network, and `ssl` makes the connection fail). While an own
453
+ server is not running, migrations and queries say so and functions that use the database time
454
+ out. That is not your code and not yours to fix: tell the person, who sees the server state in
455
+ the "Data" section of the web interface, instead of retrying.
445
456
 
446
457
  ## File storage
447
458