-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy path96-migration.rb
More file actions
54 lines (44 loc) · 1.04 KB
/
96-migration.rb
File metadata and controls
54 lines (44 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
require 'active_record'
require 'pp'
# pre-reqs
# gem install mysql2
# gem install activerecord
ActiveRecord::Base.establish_connection (
{
:adapter => "mysql2",
:host => "127.0.0.1",
:username => "tacksoo", # change username
:password => "",
:database => "gamedepot"
}
)
# create a folder called 'migrate' and place the following files in there
=begin
# file name '001_create_consoles.rb
class CreateConsoles < ActiveRecord::Migration
def change
create_table :consoles do |t|
t.string :name, :null => false
t.string :manufacturer
t.float :price, :null => false
t.integer :year
end
end
end
=end
=begin
# file name '002_create_games.rb'
class CreateGames < ActiveRecord::Migration
def change
create_table :games do |t|
t.string :name, :null => false
t.text :description
t.float :price, :null => false
t.integer :count, :null => false
t.boolean :used, :default => false
end
add_reference :games, :console
end
end
=end
ActiveRecord::Migrator.migrate('migrate')