Fogbugz #63: Tag, Monat und Jahr für Geburtstag redundant speichern, um Geburtsliste der nächsten 7 Tage fix berechnen zu können.

This commit is contained in:
Roland 2011-06-01 13:15:49 +02:00
parent fc03826cc5
commit e50cf051b5
3 changed files with 93 additions and 66 deletions

View file

@ -0,0 +1,20 @@
class RedundantBirthDateForDiff < ActiveRecord::Migration
def self.up
add_column :contacts, :birth_day, :integer
add_column :contacts, :birth_month, :integer
add_column :contacts, :birth_year, :integer
Contact.all.each do |c|
c.birth_day = c.birth_date.day unless c.birth_date.nil?
c.birth_month = c.birth_date.month unless c.birth_date.nil?
c.birth_year = c.birth_date.year unless c.birth_date.nil?
c.save!
end
end
def self.down
remove_column :contacts, :birth_year
remove_column :contacts, :birth_month
remove_column :contacts, :birth_day
end
end

View file

@ -1,65 +1,68 @@
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20110531183659) do
create_table "contacts", :force => true do |t|
t.string "firstname"
t.string "lastname"
t.string "street"
t.string "housenr"
t.string "plz"
t.string "place"
t.string "country"
t.datetime "created_at"
t.datetime "updated_at"
t.date "birth_date"
end
create_table "emails", :force => true do |t|
t.string "desc"
t.string "address"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "contact_id"
end
add_index "emails", ["contact_id"], :name => "fk_emails_contacts"
create_table "phones", :force => true do |t|
t.string "desc"
t.string "nr"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "contact_id"
end
add_index "phones", ["contact_id"], :name => "fk_phones_contacts"
create_table "users", :force => true do |t|
t.string "email", :default => "", :null => false
t.string "encrypted_password", :limit => 128, :default => "", :null => false
t.string "reset_password_token"
t.datetime "remember_created_at"
t.integer "sign_in_count", :default => 0
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "users", ["email"], :name => "index_users_on_email", :unique => true
add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
end
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20110601104452) do
create_table "contacts", :force => true do |t|
t.string "firstname"
t.string "lastname"
t.string "street"
t.string "housenr"
t.string "plz"
t.string "place"
t.string "country"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "birth_day"
t.integer "birth_month"
t.integer "birth_year"
t.date "birth_date"
end
create_table "emails", :force => true do |t|
t.string "desc"
t.string "address"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "contact_id"
end
add_index "emails", ["contact_id"], :name => "fk_emails_contacts"
create_table "phones", :force => true do |t|
t.string "desc"
t.string "nr"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "contact_id"
end
add_index "phones", ["contact_id"], :name => "fk_phones_contacts"
create_table "users", :force => true do |t|
t.string "email", :default => "", :null => false
t.string "encrypted_password", :limit => 128, :default => "", :null => false
t.string "reset_password_token"
t.datetime "remember_created_at"
t.integer "sign_in_count", :default => 0
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "users", ["email"], :name => "index_users_on_email", :unique => true
add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
end