SQL (SQLite engine)

Test a forward migration

Medium70 pts~25 min
  • Schema migrations
  • ALTER TABLE
  • Defaults
Practice app · Acme Commerce DB

A real SQL database (SQLite engine) seeded with an e-commerce and HR dataset, with schema browser and query runner.

Test URL
/lab/database-testing-test-a-forward-migration

Your starter code already declares TEST_URL — never hardcode a host.

Objective

Apply a migration that adds customers.phone and customers.tier, then verify the schema and that existing rows got the default.

Your task

  1. 1ALTER TABLE customers ADD COLUMN phone TEXT.
  2. 2ALTER TABLE customers ADD COLUMN tier TEXT NOT NULL DEFAULT 'standard'.
  3. 3Inspect the schema with SELECT name, type, "notnull", dflt_value FROM pragma_table_info('customers').
  4. 4Verify the data: SELECT tier, COUNT(*) AS customers, COUNT(phone) AS with_phone FROM customers GROUP BY tier.

Acceptance criteria

  • customers has the phone and tier columns with the expected types and default
  • The last result set is ('standard', 30, 0)
  • The script uses ALTER TABLE

Constraints

  • Every run starts from a freshly seeded database, so your script must include its own setup statements.
  • Dialect: SQLite. ALTER TABLE supports ADD COLUMN, DROP COLUMN and RENAME; other type changes need a table rebuild.
  • Only the last result set of your script is compared, so finish with the verification query.

SQL (SQLite engine) · Database Testing · Migrations & schema