| 23 | | end |
| 24 | | |
| 25 | | Blog::Models.schema do |
| 26 | | create_table :blog_posts, :force => true do |t| |
| 27 | | t.column :id, :integer, :null => false |
| 28 | | t.column :user_id, :integer, :null => false |
| 29 | | t.column :title, :string, :limit => 255 |
| 30 | | t.column :body, :text |
| 31 | | end |
| 32 | | create_table :blog_users, :force => true do |t| |
| 33 | | t.column :id, :integer, :null => false |
| 34 | | t.column :username, :string |
| 35 | | t.column :password, :string |
| 36 | | end |
| 37 | | create_table :blog_comments, :force => true do |t| |
| 38 | | t.column :id, :integer, :null => false |
| 39 | | t.column :post_id, :integer, :null => false |
| 40 | | t.column :username, :string |
| 41 | | t.column :body, :text |
| 42 | | end |
| 43 | | execute "INSERT INTO blog_users (username, password) VALUES ('admin', 'camping')" |
| | 18 | |
| | 19 | class CreateTheBasics < V 1.0 |
| | 20 | def self.up |
| | 21 | create_table :blog_posts, :force => true do |t| |
| | 22 | t.column :id, :integer, :null => false |
| | 23 | t.column :user_id, :integer, :null => false |
| | 24 | t.column :title, :string, :limit => 255 |
| | 25 | t.column :body, :text |
| | 26 | end |
| | 27 | create_table :blog_users, :force => true do |t| |
| | 28 | t.column :id, :integer, :null => false |
| | 29 | t.column :username, :string |
| | 30 | t.column :password, :string |
| | 31 | end |
| | 32 | create_table :blog_comments, :force => true do |t| |
| | 33 | t.column :id, :integer, :null => false |
| | 34 | t.column :post_id, :integer, :null => false |
| | 35 | t.column :username, :string |
| | 36 | t.column :body, :text |
| | 37 | end |
| | 38 | User.create :username => 'admin', :password => 'camping' |
| | 39 | end |
| | 40 | def self.down |
| | 41 | drop_table :blog_posts |
| | 42 | drop_table :blog_users |
| | 43 | drop_table :blog_comments |
| | 44 | end |
| | 45 | end |