class FirstWhack < ActiveRecord::Migration
def self.up create_table :cards, :force=>true do |t|
t.column :title, :string, :null=>false # Name of the card. "Jumpin' Jesus on a Pogo-Stick"
t.column :img, :string # A fully-qualified URL or local filename. Null implies "blank"!
t.column :effect, :string # Psuedo-code. Ex: "modify 1 cards where target has tag 2" Optional
t.column :action, :string # Describe the effect. "Play on a blue card--change the image." Optional.
t.column :points, :integer, :null=>false, :default=>0
t.column :player_id, :integer # Current owner, null is discards
t.column :game_id, :integer, :null=>false
t.column :created_at, :datetime, :null=>false
t.column :created_by, :integer, :null=>false # fk to players
end
create_table :tags, :force=>true do |t|
t.column :name, :string, :null=>false
end
create_table :cards_tags, :force=>true do |t|
t.column :card_id, :integer, :null=>false
t.column :tag_id, :integer, :null=>false
t.column :player_id, :integer # Who created it? If null, it was auto-added (ex: "blank")
t.column :created_at, :datetime, :null=>false
end
create_table :players, :force=>true do |t|
t.column :name, :string, :null=>false, :limit=>128
t.column :born_on, :date, :null=>false # So we know their age (and birthday?) - play will be youngest -> oldest
t.column :email, :string # Notification of turns. Optional.
t.column :img, :string # Full URL or local filename. Optional.
end
# Apparantly we've got a Catch-22, here: I don't yet have a Player object. Hmmmn.
# jr = Player.create :name=>"Jeremy Rice", :born_on=>Date.civil(1974,8,7), :email => "jrice.blue@gmail.com"
create_table :players_tags, :force=>true do |t|
t.column :player_id, :integer, :null=>false
t.column :tag_id, :integer, :null=>false
end
create_table :games, :force=>true do |t|
t.column :name, :string, :null=>false # Name of the game: "Teh Interwebs is 4 p0rn///"
t.column :current_player, :integer # Null until the game starts. Fk to players.
t.column :turn_order_sort, :string, :limit=>4 # Null for ASC, otherwise "DESC".
t.column :created_at, :datetime
t.column :started_at, :datetime
end
create_table :games_players, :force=>true do |t|
t.column :player_id, :integer, :null=>false
t.column :game_id, :integer, :null=>false
t.column :ready_to_start_at, :datetime # Null until the player has created their first 5 cards.
t.column :joined_at, :datetime
end
# This will store each play in a game. Useful for undos, but might also produce a kind of history.
create_table :plays, :force=>true do |t|
t.column :player_id, :integer, :null=>false
t.column :game_id, :integer, :null=>false
t.column :card_id, :integer, :null=>false
t.column :comment, :text # Jibe from the player; optional.
t.column :targets, :text # Not yet sure how I'll store this, but it'll be an array of objects.
end
end
def self.down
drop_table :cards
drop_table :tags
drop_table :cards_tags
drop_table :players
drop_table :players_tags
drop_table :games
drop_table :games_players
drop_table :plays
end
end