Permalink
Browse files

More markdown fixes.

  • Loading branch information...
1 parent d2f35fc commit aecb0aa657cae8a421c8809034e43dcd439e8d86 @rsandor committed May 2, 2010
Showing with 53 additions and 53 deletions.
  1. +53 −53 README.markdown
View
@@ -61,19 +61,19 @@ What is a migration?
A migration is a programmatic way of defining incremental database schema
changes. It has an "up" method for describing how to apply the changes, and a
"down" method for removing them. Here is an example migration:
- var create_users_table = new Migration({
- up: function() {
- this.create_table('users', function(t) {
- t.integer('id');
- t.string('email');
- t.string('password');
- t.primary_key('id');
- });
- },
- down: function() {
- this.drop_table('users');
- }
- });
+ var create_users_table = new Migration({
+ up: function() {
+ this.create_table('users', function(t) {
+ t.integer('id');
+ t.string('email');
+ t.string('password');
+ t.primary_key('id');
+ });
+ },
+ down: function() {
+ this.drop_table('users');
+ }
+ });
In the above migration the "up" function creates a table named "users" with
three fields (id, email, and password) and a primary key on id. The "down"
function reverses these changes and simply drops the entire "users" table.
@@ -113,23 +113,23 @@ and options are as explained in the `t.column` method. Here's a complete list:
`date`, `binary`, `boolean`
Example:
- this.create_table('high_scores', function(t) {
- t.integer('id');
- t.string('name', {limit: 32});
- t.create('score', 'integer', {limit: 8})
- t.datetime('date');
- t.primary_key('id');
- t.index('name');
- });
+ this.create_table('high_scores', function(t) {
+ t.integer('id');
+ t.string('name', {limit: 32});
+ t.create('score', 'integer', {limit: 8})
+ t.datetime('date');
+ t.primary_key('id');
+ t.index('name');
+ });
Producing SQL:
- CREATE TABLE high_scores (
- id INT,
- name VARCHAR(32),
- score BIGINT,
- date DATETIME,
- PRIMARY KEY (id),
- INDEX (name)
- );
+ CREATE TABLE high_scores (
+ id INT,
+ name VARCHAR(32),
+ score BIGINT,
+ date DATETIME,
+ PRIMARY KEY (id),
+ INDEX (name)
+ );
### drop_table(name)
Simply drops a table from the schema. Example:
@@ -161,26 +161,26 @@ modify existing tables and adds the following functionality to body method:
* `t.remove_primary_key()` - Removes a primary key from the table.
Example:
- this.change_table('all_time_high_scores', function(t) {
- t.remove_index('name');
- t.remove_primary_key();
- t.remove('date');
- t.date('date');
- t.rename('score' {
- name: 'high_score',
- type: 'integer',
- limit: 4
+ this.change_table('all_time_high_scores', function(t) {
+ t.remove_index('name');
+ t.remove_primary_key();
+ t.remove('date');
+ t.date('date');
+ t.rename('score' {
+ name: 'high_score',
+ type: 'integer',
+ limit: 4
+ });
+ t.change('name', 'string' {limit: 128});
});
- t.change('name', 'string' {limit: 128});
- });
Producing SQL:
- ALTER TABLE all_time_high_scores
- DROP INDEX (name),
- DROP PRIMARY KEY,
- DROP COLUMN 'date',
- ADD COLUMN date DATE,
- CHANGE COLUMN score high_score INT,
- MODIFY COLUMN name VARCHAR(128);
+ ALTER TABLE all_time_high_scores
+ DROP INDEX (name),
+ DROP PRIMARY KEY,
+ DROP COLUMN 'date',
+ ADD COLUMN date DATE,
+ CHANGE COLUMN score high_score INT,
+ MODIFY COLUMN name VARCHAR(128);
### add_column(table_name, column_name, type, options)
Adds a column to a table. Example:
@@ -193,13 +193,13 @@ Producing SQL:
### rename_column(table_name, column_name, new_column)
Renames and modifies a column in a table. Example:
- this.rename('all_time_high_scores', 'high_score', {
- name: 'score',
- type: 'integer',
- limit: 8
- });
+ this.rename('all_time_high_scores', 'high_score', {
+ name: 'score',
+ type: 'integer',
+ limit: 8
+ });
Producing SQL:
- ALTER TABLE all_time_high_scores CHANGE COLUMN high_score score BIGINT;
+ ALTER TABLE all_time_high_scores CHANGE COLUMN high_score score BIGINT;
### change_column(table_name, column_name, type, options)
Changes a column's definition. Example:

0 comments on commit aecb0aa

Please sign in to comment.