gpt4 book ai didi

mysql - 将 ruby​​ on rails 应用程序的数据库从 sql server 转换为 mysql

转载 作者:行者123 更新时间:2023-11-30 22:02:39 25 4
gpt4 key购买 nike

我用 sql server 克隆了一个 ruby​​ on rails 应用,代码如下:

# Gemfile
gem 'tiny_tds'
gem 'activerecord-sqlserver-adapter', '~> 4.2.0'

database.yml

default: &default
adapter: sqlserver
azure: true

development: &development
<<: *default
host: <%= ENV['DATABASE_HOST'] %>
database: <%= ENV['DATABASE_NAME'] %>
username: <%= ENV['DATABASE_USER'] %>
password: <%= ENV['DATABASE_PASS'] %>

development_vehicle: &development_vehicle
<<: *default
host: <%= ENV['DATABASE_VEHICLE_HOST'] || ENV['DATABASE_HOST'] %>
database: <%= ENV['DATABASE_VEHICLE_NAME'] || ENV['DATABASE_NAME'] %>
username: <%= ENV['DATABASE_VEHICLE_USER'] || ENV['DATABASE_USER'] %>
password: <%= ENV['DATABASE_VEHICLE_PASS'] || ENV['DATABASE_PASS'] %>

development_aspnet: &development_aspnet
<<: *default
host: <%= ENV['DATABASE_ASPNETDB_HOST'] || ENV['DATABASE_HOST'] %>
database: <%= ENV['DATABASE_ASPNETDB_NAME'] || ENV['DATABASE_NAME'] %>
username: <%= ENV['DATABASE_ASPNETDB_USER'] || ENV['DATABASE_USER'] %>
password: <%= ENV['DATABASE_ASPNETDB_PASS'] || ENV['DATABASE_PASS'] %>

db 文件夹如:

enter image description here

但我的本地使用mysql,所以我想使用mysql代替sql server来构建这个应用程序

你能帮我转换一下吗?谢谢!

最佳答案

gem 文件

# gem 'tiny_tds'
# gem 'activerecord-sqlserver-adapter', '~> 4.2.0'
gem 'mysql2'

配置/数据库.yml

default: &default
adapter: mysql2
pool: 5
timeout: 5000
username : root #mysql username
password : root #mysql password

development:
<<: *default
database: db_name

test:
<<: *default
database: db_name

production:
<<: *default
database: db_name

关于mysql - 将 ruby​​ on rails 应用程序的数据库从 sql server 转换为 mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42897265/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com