我有一个rails应用程序,它在生产中运行MySQL,在开发中运行SQLite。在开发模式下,一切正常,但在生产中,datetime属性不会保存到数据库中(即使create_at和updated_at也不会)。该字段不是null
,而是0000-00-00 00:00:00
。这怎么可能?我做了一些研究,但我无法修复它。
schema.rb:
# encoding: UTF-8
# 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 => 20130306100623) do
create_table "announcements", :force => true do |t|
t.string "title"
t.text "text"
t.integer "user_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "delayed_jobs", :force => true do |t|
t.integer "priority", :default => 0
t.integer "attempts", :default => 0
t.text "handler"
t.text "last_error"
t.datetime "run_at"
t.datetime "locked_at"
t.datetime "failed_at"
t.string "locked_by"
t.string "queue"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority"
create_table "document_categories", :force => true do |t|
t.string "title"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "documents", :force => true do |t|
t.string "file_file_name"
t.string "file_content_type"
t.integer "file_file_size"
t.datetime "file_updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "user_id"
t.string "title"
t.text "description"
t.string "ancestry"
t.boolean "folder"
end
add_index "documents", ["ancestry"], :name => "index_documents_on_ancestry"
create_table "inventory_items", :force => true do |t|
t.string "object"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "reservation_items", :force => true do |t|
t.integer "reservation_id"
t.integer "inventory_item_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "reservations", :force => true do |t|
t.integer "user_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "start_time"
t.datetime "end_time"
end
create_table "users", :force => true do |t|
t.string "first_name"
t.string "insertion"
t.string "last_name"
t.string "telephone_prefix"
t.string "telephone_suffix"
t.string "address"
t.string "number"
t.string "postal_code"
t.string "city"
t.date "birthdate"
t.string "email", :default => "", :null => false
t.string "encrypted_password", :default => "", :null => false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
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", :null => false
t.datetime "updated_at", :null => false
t.string "telephone_mobile"
t.integer "admin"
t.string "avatar_file_name"
t.string "avatar_content_type"
t.integer "avatar_file_size"
t.datetime "avatar_updated_at"
t.string "sex"
t.string "lovo_email"
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
非常感谢!