运行 heroku rake db:migrate 已中止
这是我的迁移文件:
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.string :login, :null => false # optional, see below
t.string :crypted_password, :null => false # optional, see below
t.string :password_salt, :null => false # optional, but highly recommended
t.string :email, :null => false # optional, you can use login instead, or both
t.string :persistence_token, :null => false # required
t.string :single_access_token, :null => false # optional, see Authlogic::Session::Params
t.string :perishable_token, :null => false # optional, see Authlogic::Session::Perishability
# Magic columns, just like ActiveRecord's created_at and updated_at. These are automatically maintained by Authlogic if they are present.
t.integer :login_count, :null => false, :default => 0 # optional, see Authlogic::Session::MagicColumns
t.integer :failed_login_count, :null => false, :default => 0 # optional, see Authlogic::Session::MagicColumns
t.datetime :last_request_at # optional, see Authlogic::Session::MagicColumns
t.datetime :current_login_at # optional, see Authlogic::Session::MagicColumns
t.datetime :last_login_at # optional, see Authlogic::Session::MagicColumns
t.string :current_login_ip # optional, see Authlogic::Session::MagicColumns
t.string :last_login_ip # optional, see Authlogic::Session::MagicColumns
t.string :name, :null => false, :default => ''
t.string :gender, :null => false, :default => ''
t.datetime :dob, :null => false, :default => ''
t.timestamps
end
end
def self.down
drop_table :users
end
end
当我想将应用程序推送到heroku并运行heroku rake db:migrate
时,出现以下错误:
== CreateUsers: migrating ====================================================
-- create_table(:users)
rake aborted!
An error has occurred, this and all later migrations canceled:
PGError: ERROR: invalid input syntax for type timestamp: ""
: CREATE TABLE "users" ("id" serial primary key, "login" character varying(255) NOT NULL, "crypted_password" character varying(255) NOT NULL, "password_salt" character varying(255) NOT NULL, "email" character varying(255) NOT NULL, "persistence_token" character varying(255) NOT NULL, "single_access_token" character varying(255) NOT NULL, "perishable_token" character varying(255) NOT NULL, "login_count" integer DEFAULT 0 NOT NULL, "failed_login_count" integer DEFAULT 0 NOT NULL, "last_request_at" timestamp, "current_login_at" timestamp, "last_login_at" timestamp, "current_login_ip" character varying(255), "last_login_ip" character varying(255), "name" character varying(255) DEFAULT '' NOT NULL, "gender" character varying(255) DEFAULT '' NOT NULL, "dob" timestamp DEFAULT '' NOT NULL, "created_at" timestamp, "updated_at" timestamp)
(See full trace by running task with --trace)
我做错了什么?谢谢。
This is my migration file:
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.string :login, :null => false # optional, see below
t.string :crypted_password, :null => false # optional, see below
t.string :password_salt, :null => false # optional, but highly recommended
t.string :email, :null => false # optional, you can use login instead, or both
t.string :persistence_token, :null => false # required
t.string :single_access_token, :null => false # optional, see Authlogic::Session::Params
t.string :perishable_token, :null => false # optional, see Authlogic::Session::Perishability
# Magic columns, just like ActiveRecord's created_at and updated_at. These are automatically maintained by Authlogic if they are present.
t.integer :login_count, :null => false, :default => 0 # optional, see Authlogic::Session::MagicColumns
t.integer :failed_login_count, :null => false, :default => 0 # optional, see Authlogic::Session::MagicColumns
t.datetime :last_request_at # optional, see Authlogic::Session::MagicColumns
t.datetime :current_login_at # optional, see Authlogic::Session::MagicColumns
t.datetime :last_login_at # optional, see Authlogic::Session::MagicColumns
t.string :current_login_ip # optional, see Authlogic::Session::MagicColumns
t.string :last_login_ip # optional, see Authlogic::Session::MagicColumns
t.string :name, :null => false, :default => ''
t.string :gender, :null => false, :default => ''
t.datetime :dob, :null => false, :default => ''
t.timestamps
end
end
def self.down
drop_table :users
end
end
When I wanna push the app to heroku, and run heroku rake db:migrate
, the following errors appeared:
== CreateUsers: migrating ====================================================
-- create_table(:users)
rake aborted!
An error has occurred, this and all later migrations canceled:
PGError: ERROR: invalid input syntax for type timestamp: ""
: CREATE TABLE "users" ("id" serial primary key, "login" character varying(255) NOT NULL, "crypted_password" character varying(255) NOT NULL, "password_salt" character varying(255) NOT NULL, "email" character varying(255) NOT NULL, "persistence_token" character varying(255) NOT NULL, "single_access_token" character varying(255) NOT NULL, "perishable_token" character varying(255) NOT NULL, "login_count" integer DEFAULT 0 NOT NULL, "failed_login_count" integer DEFAULT 0 NOT NULL, "last_request_at" timestamp, "current_login_at" timestamp, "last_login_at" timestamp, "current_login_ip" character varying(255), "last_login_ip" character varying(255), "name" character varying(255) DEFAULT '' NOT NULL, "gender" character varying(255) DEFAULT '' NOT NULL, "dob" timestamp DEFAULT '' NOT NULL, "created_at" timestamp, "updated_at" timestamp)
(See full trace by running task with --trace)
What have I done wrong? Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的 dob 默认为 ''。这在 Postgres 中无效。将列类型更改为字符串或默认为 null,或者创建一个新的日期对象并将其默认为该对象
You have dob defaulting to ''. This isn't valid in Postgres. Either change the column type to string or default to null or create a new date object and default it to that