

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 5
click for more info
Not enough gems
Cost: 6 gems
1: Creating a Table
incomplete
2: Create Table Practice
incomplete
3: Altering Tables
incomplete
4: Intro to Migrations
incomplete
5: Up Migration
incomplete
6: Down Migration
incomplete
7: Migration Review
incomplete
8: SQL Data Types
incomplete
9: Practice – Posts Table
incomplete
10: Practice – Posts Table Migration
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
To manage migrations, we use a simple system based on up and down directions.
This allows developers to safely move between versions of the schema during development and production rollouts.
Let's write the SQL for an up migration to add new features to our database.
We're going to add more columns to the transactions table. We need to know whether or not each transaction between two users was successfully completed. Our database should also track the type of transaction.
The transactions table looks like this at the moment:
| cid | name | type | notnull | dflt_value | pk |
|---|---|---|---|---|---|
| 0 | id | INTEGER | 0 | 0 | |
| 1 | recipient_id | INTEGER | 0 | 0 | |
| 2 | sender_id | INTEGER | 0 | 0 | |
| 3 | note | TEXT | 0 | 0 | |
| 4 | amount | REAL | 0 | 0 |
Complete the following SQL statements in this order:
BOOL is technically valid, but the assignment expects BOOLEAN – so use BOOLEAN instead of BOOL to pass.