Schema sync
Pull the chosen live schemas of a database connection into the design, previewed, then applied as one undoable edit.
The schema sync brings a database's design in line with what its live database holds. It reads the chosen schemas through one of the database's connections, shows what would change, and changes the design only when you apply. It never writes to the live database: the live database is the source, the design the target.
Use it after a migration ran, or to bring a database that changed outside Architure back in step. For a first look at a database that has no connection, import its schema instead.
Start a sync
Open the database's canvas, choose Connections in the top bar, then Sync… on the row of the connection to read. The Sync from the live database dialog opens and reads the live schemas through that connection.
Owners, admins and members sync, while the organization has an active trial or subscription. Viewers do not see the connections, and agents have no tool for it.
1. Choose the schemas
The dialog lists the live schemas with their table counts. In Architure marks a schema the design already has. Those are ticked at first; when the design has none of them, every schema is ticked. Tick the ones to sync, then Preview.
A MySQL connection has one schema: the database named in its URL, which syncs into public, as an import maps it. The URL must name a database.
2. Preview
Architure reads the chosen schemas and compares them with the design by name: schemas, then tables by schema and name, then the columns, indexes and foreign keys of each table. The preview opens with a summary per group, counted in schemas, tables, columns, indexes and foreign keys:
- New: what the live database has and the design lacks. A live schema the design lacks is created. A new enum type proposes a new column definition, listed under "New column definitions".
- Changed: what differs, for example a data type (
text → character varying(120)), NOT NULL, a default, a key, an index's columns or a foreign key's actions. - Only in Architure: tables, columns, indexes and foreign keys of the chosen schemas that the live database lacks, such as tables planned in Architure or dropped live. They are kept.
Then each table that changes is listed with its schema, its column count, its group and its lines: + for what is new, ~ for what changed, − for what is only in Architure.
Tick Also remove what is only in Architure to make the chosen schemas mirror the live database: the preview counts what goes, and the apply removes it. Left unticked, nothing is removed.
Under skipped or approximated, the preview lists what the design cannot hold, as an import of the catalog query does: the expression of a generated column, the condition of a partial index, an index on an expression, a foreign key to a table outside the chosen schemas that the design does not have. A foreign key to such a table that the design has, by schema and name, is kept. Views, functions and triggers are not read at all. When nothing differs, the dialog says "No changes: the chosen schemas match the live database." Back returns to the schemas.
3. Apply
Apply changes creates the proposed column definitions in the organization, then applies every change to the design as one edit. A notice says what was added, changed and removed, with Undo; Undo in the top bar reverts the whole sync too. New tables appear on a grid under the existing ones: Auto-layout arranges them.
Teammates and agents may change the database while the preview is open. The dialog computes the changes again when you apply. If the result differs from the preview, nothing is applied: the dialog shows the new preview and says "The model changed since the preview: check it again, then apply."
What the live database wins on
For every matched table, the live values replace the design's: data types (compared by meaning, so int4 equals integer), NOT NULL, defaults, primary keys, unique and auto-increment flags, the order of the live columns, an index's columns and uniqueness, a foreign key's name, cardinality and actions.
A renamed table, column or index cannot be matched by name: it shows as one removal and one addition.
What stays
- The position, area and information type of every matched table and column.
- Descriptions. A live comment fills only an empty description; a description written in Architure always wins.
- Table relationships, which exist only in Architure.
- Schemas you did not choose. A schema is never deleted.
- Column definitions. A sync never edits one. A column linked to a definition stays linked while the definition's data type is the live type; otherwise it is unlinked, takes the live type and keeps its information type. A live enum links to a definition with the same name and values, or proposes a new one (a taken name gets a
_2suffix and a warning).
Limits
- Each read runs the catalog query in a read-only transaction, with a 30-second limit, through the same public-address check as a test. The catalog is not stored.
- Reading the schemas and the preview each count against the ten connection tests a minute per organization.
- One preview reads at most about 4 MB of catalog: sync a large database a few schemas at a time.
- The outcome of each read is shown on the connection like a test: Connected, or Failed with the message.
Database connections
Store how to reach a database in each environment, encrypted, test it from Architure's servers, and sync its schemas into the design.
Text format reference
The text view's format, DBML plus information types, column definitions and coloured areas, and how an edit in text is applied.