`

postgresql怎么用change.column

阅读更多
def up
    connection.execute(%q{
        alter table contests
        alter column prize type integer using cast(prize as integer),
        alter column price set default 200
    })
end

def up
    case ActiveRecord::Base.connection
    when ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
        connection.execute(%q{
            alter table contests
            alter column prize type integer using cast(prize as integer),
            alter column price set default 200
        })
    when ActiveRecord::ConnectionAdapters::MySQLAdapter
        # MySQL version...
    end
end


rails 中怎么truncate table
ActiveRecord::Base.connection.execute("TRUNCATE TABLE #{table_name}")
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics