我有这个迁移文件:
class InitialDigitizationWork < ActiveRecord::Migration
def self.up
create_table :digitizations do |t|
t.string :submission_code, :null => false
t.timestamps
end
add_index :digitizations, :submission_code, :unique => true
create_table :digitized_pieces do |t|
t.integer :digitization_id, :null => false
t.integer :position, :null => false
t.string :piece_type, :default => "Page"
t.timestamps
end
add_index :digitized_pieces, :digitization_id
create_table :digitized_views do |t|
t.integer :digitized_piece_id, :null => false
t.string :initial_file_name
t.string :attachment_file_name
t.string :attachment_content_type
t.integer :attachment_file_size
t.datetime :attachment_updated_at
t.integer :position, :null => false
t.boolean :is_primary, :default => false
t.timestamps
end
add_index :digitized_views, :digitized_piece_id, :null => false
end它在最后一行失败:
-- add_index(:digitized_views, :digitized_piece_id, {:null=>false})
rake aborted!
StandardError: An error has occurred, all later migrations canceled:
Unknown key: :null. Valid keys are: :unique, :order, :name, :where, :length, :internal, :using, :algorithm,有人知道这是怎么回事吗?
这里令人恼火的是,由于最后一行失败,我不能再次重新运行迁移,因为顶层digitizations上的表存在。我知道如何使用Postgresql并访问由这个yml文件指定创建的特定表:
#SQLite version 3.x
#gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
adapter: mysql2
database: arthouse_development
username: root
password:
host: localhost
port: 3306
#socket: /tmp/mysql.sock
legacy_development:
adapter: mysql2
database: arthouse_legacy_development
username: root
password:
host: localhost
port: 3306有谁知道我如何在这里通过控制台进入数据库?
有人知道可能会发生什么吗?这是我第一次使用mysql,需要一些帮助。
同样,当我输入mysql时,也会发生这种情况:
mysql
ERROR 1045 (28000): Access denied for user 'jwan'@'localhost' (using password: NO)但这是可行的:
mysql -u root我每次都要这么做吗?
发布于 2017-11-02 07:22:43
好的,下面是你需要做的:
首先回滚上一次迁移,这样您就可以从头开始:
rake db:rollback然后删除索引上的default=> null约束。错误消息明确指出它不是已知的key
未知密钥::null。有效键为::唯一,:顺序,:名称,:其中,:长度,:内部,:使用,:算法,
然后重新运行迁移:
rake db:migratehttps://stackoverflow.com/questions/47064934
复制相似问题