English 中文(简体)
db:与邮局比较。 如何确定已经存在的用户
原标题:db:migrate with postgres. How to fix users already exists

这里还有另一个问题,试图不向许多人提问,而是把打上围墙。 滚动干.:与电站相距,并得出以下错误。 如何确定用户?

$ rake db:migrate
==  CreateUsers: migrating ====================================================
-- create_table(:users)
NOTICE:  CREATE TABLE will create implicit sequence "users_id_seq1" for serial column "users.id"
rake aborted!
An error has occurred, this and all later migrations canceled:

PGError: ERROR:  relation "users" already exists
: CREATE TABLE "users" ("id" serial primary key, "first_name" character varying(25),     "last_name" character varying(50), "email" character varying(255) DEFAULT    NOT NULL,    "password" character varying(40), "created_at" timestamp, "updated_at" timestamp) 

Tasks: TOP => db:migrate

页: 1

class CreateUsers < ActiveRecord::Migration
  def up
    create_table :users do |t|
      t.string "first_name", :limit => 25
      t.string "last_name", :limit => 50
      t.string "email", :default => "", :null => false
      t.string "password", :limit => 40
      t.timestamps
    end
  end

  def down
    drop_table :users
  end
end
问题回答

可在<代码>create_table users do :users do > >上登上drop_table :users。 ONLY DO THIS FI YOU HAVE NO DATA to LOSE!

如果您希望添加以下栏目:add_column,用于每一行:add_column :users, :name, :string





相关问题
摘录数据

我如何将Excel板的数据输入我的Django应用? I m将PosgreSQL数据库作为数据库。

Postgres dump of only parts of tables for a dev snapshot

On production our database is a few hundred gigabytes in size. For development and testing, we need to create snapshots of this database that are functionally equivalent, but which are only 10 or 20 ...

How to join attributes in sql select statement?

I want to join few attributes in select statement as one for example select id, (name + + surname + + age) as info from users this doesn t work, how to do it? I m using postgreSQL.

What text encoding to use?

I need to setup my PostgreSQL DB s text encoding to handle non-American English characters that you d find showing up in languages such as German, Spanish, and French. What character encoding should ...

SQL LIKE condition to check for integer?

I am using a set of SQL LIKE conditions to go through the alphabet and list all items beginning with the appropriate letter, e.g. to get all books where the title starts with the letter "A": SELECT * ...

热门标签