Moving the Data

Moving the schema is easy. Moving the data is the work.

Django will create the tables in Postgres from your existing migrations without complaint. What it will not do is fix rows that were only ever valid because SQLite did not check them.

The audit, in order. Before moving anything, run these against the SQLite database and look at what comes back.

Columns declared as one type holding another.

Foreign keys pointing at rows that do not exist, which SQLite permitted while enforcement was off.

Duplicate values in a column you now want UNIQUE.

Nulls in a column you now want NOT NULL.

Text in a date column that will not parse.

Every one of those is a decision, not a delete. Fix it, or record why you dropped it and how many rows that was.

◈ Graded Query

Find the rows a foreign key would reject. Return the id and title of every workshop whose venue_id points at a venue that does not exist. A workshop with no venue at all is not an orphan; it is simply unassigned. Two columns, ordered by id.

Checked against the rows your query returns. 1 visible and 3 hidden checks, some against data you cannot see.

loading editor…

Mark this lesson complete

Signed in, your progress follows you to every device.

Next: The Cutover →
← Back