我有以下 MySQL RoR 迁移:
class ReindexRpushNotification < ActiveRecord::Migration
def up
execute("DROP INDEX `index_rpush_notifications_multi` ON rpush_notifications;")
execute("ALTER TABLE rpush_notifications ADD INDEX index_rpush_notifications_multi (delivered, failed, processing, deliver_after), ALGORITHM=INPLACE, LOCK=NONE;")
end
def down
execute("DROP INDEX `index_rpush_notifications_multi` ON rpush_notifications;")
execute("ALTER TABLE rpush_notifications ADD INDEX index_rpush_notifications_multi (delivered, failed), ALGORITHM=INPLACE, LOCK=NONE;")
end
end
Run Code Online (Sandbox Code Playgroud)
在这次迁移期间,我正在尝试执行一些请求(GET、COUNT、DELETE、UPDATE)但没有任何效果,所有这些请求都在等待
我在这里找到了有关在后台创建索引的信息
http://dev.mysql.com/doc/refman/5.6/en/innodb-create-index-overview.html
但它对我们不起作用
有人试过LOCK=NONE吗?
我们在 AWS RDS 上使用 MySQL 5.6.23
我在 RDS 上创建了数据库实例并使用了以下功能。它在本地开发机器上使用相同的 PostgreSQL 版本时出错。
create or replace function uuid() returns uuid as 'uuid-ossp', 'uuid_generate_v1' volatile strict language C;
Run Code Online (Sandbox Code Playgroud)
这是错误日志:
Run Code Online (Sandbox Code Playgroud)ERROR: permission denied for language c ********** Error ********** ERROR: permission denied for language c SQL state: 42501
我在 ruby on rails 3.2 中使用此函数为我的模式生成 uuid。
postgresql postgresql-9.2 postgresql-9.3 rails postgresql-extensions
我在试图改变类型的列时,这个错误time
类型为timestamp
:
PG::CannotCoerce: ERROR: cannot cast type time without time zone to timestamp without time zone
Run Code Online (Sandbox Code Playgroud)
现有时间如何转换对我来说并不重要,但我确实需要更改此列。我怎么能强制这个或投这个?
这是 SQL 语句:
ALTER TABLE "students" ALTER COLUMN "time_since_missing_schedule_notification" TYPE timestamp USING CAST(time_since_missing_schedule_notification AS timestamp)
Run Code Online (Sandbox Code Playgroud)
我正在使用 Rails/ActiveRecord,这是生成上述 SQL 语句的 Ruby 代码:
change_column :students, :time_since_missing_schedule_notification, 'timestamp USING CAST(time_since_missing_schedule_notification AS timestamp without time zone)'
Run Code Online (Sandbox Code Playgroud)
当我连接到 Heroku 的 PostgreSQL 服务器时,我得到以下版本:
psql (9.3.1, server 9.2.7)
Run Code Online (Sandbox Code Playgroud)