aboutsummaryrefslogtreecommitdiffstats
path: root/db/migrate/050_improve_track_things.rb
blob: 430dd5946348eea585b4ab73d06b6637cef470ca (plain)
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
class ImproveTrackThings < ActiveRecord::Migration
    def self.up
        # SQLite at least needs a default for this
        add_column :track_things, :track_type, :string, :null => false, :default => "internal_error"

        add_column :track_things, :created_at, :datetime
        add_column :track_things, :updated_at, :datetime
        add_column :track_things_sent_emails, :created_at, :datetime
        add_column :track_things_sent_emails, :updated_at, :datetime

        add_column :users, :last_daily_track_email, :datetime
        User.update_all "last_daily_track_email = '2000-01-01'"
        change_column :users, :last_daily_track_email, :datetime, :default => "2000-01-01"
    end

    def self.down
        remove_column :track_things, :track_type

        remove_column :track_things, :created_at
        remove_column :track_things, :updated_at
        remove_column :track_things_sent_emails, :created_at
        remove_column :track_things_sent_emails, :updated_at

        remove_column :users, :last_daily_track_email
    end
end