我正在使用Nginx,Capistrano,Rails运行服务器
我在本地计算机上进行了一些db:migrations,然后想要将这些更改推送到我的服务器。但是,我无法弄清楚如何在服务器上迁移我的数据库。我该怎么做?
我试过
1)
cap production deploy
cap production deploy:migrate
2)
[On server - in current]
rake db:migrate
但这些似乎都不起作用。如何进行此迁移?
Capistrano档案
lock '3.4.0'
require 'capistrano/sidekiq'
set :whenever_command, "bundle exec whenever"
require "whenever/capistrano"
set :application, 'myApp'
set :repo_url, 'git...'
set :keep_releases, 5
set :scm, :git
set :repository, "git..."
set :scm_passphrase, "..."
set :user, "..."
set :use_sudo, false
set :deploy_to, "/.../.../apps/appName"
namespace :deploy do
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
end
end
end
答案 0 :(得分:1)
1)如果您使用的是capistrano-rails,则应设置
set :migration_role, 'migrator' # Defaults to 'db'
2)在服务器上,您正在开发环境中进行迁移,请尝试
RAILS_ENV=production bundle exec rails db:migrate
答案 1 :(得分:0)
要使用capistrano运行迁移,在保留在HorzScrollBox
内的object GridViewForm: TGridViewForm
Left = 0
Top = 0
Caption = 'Grid Form'
ClientHeight = 946
ClientWidth = 2600
StyleBook = StyleBook2
FormFactor.Width = 1280
FormFactor.Height = 1024
FormFactor.Devices = [dkDesktop]
FormFamily = 'Main'
FullScreen = True
OnMouseUp = FormMouseUp
Touch.InteractiveGestures = [igPan]
OnGesture = FormGesture
DesignerMobile = False
DesignerWidth = 0
DesignerHeight = 0
DesignerDeviceName = ''
DesignerOrientation = 0
DesignerOSVersion = ''
object MainLayout: TLayout
Align = alContents
Height = 921.000000000000000000
Margins.Top = 25.000000000000000000
Width = 2600.000000000000000000
object HorzScrollBox1: THorzScrollBox
Align = alClient
Height = 921.000000000000000000
TabOrder = 0
Width = 2600.000000000000000000
object GroupLayout1: TLayout
Align = alLeft
Anchors = [akLeft, akTop]
Height = 905.000000000000000000
Margins.Left = 110.000000000000000000
Position.X = 110.000000000000000000
Width = 540.000000000000000000
object ListBox4: TListBox
Align = alClient
Height = 905.000000000000000000
StyleLookup = 'collectionlistbox'
TabOrder = 0
Width = 540.000000000000000000
DefaultItemStyles.ItemStyle = ''
DefaultItemStyles.GroupHeaderStyle = ''
DefaultItemStyles.GroupFooterStyle = ''
end
end
object GroupLayout2: TLayout
Align = alLeft
Anchors = [akLeft, akTop]
Height = 905.000000000000000000
Margins.Left = 40.000000000000000000
Position.X = 690.000000000000000000
Width = 1225.000000000000000000
end
object Layout1: TLayout
Align = alLeft
Anchors = [akLeft, akTop]
Height = 905.000000000000000000
Margins.Left = 40.000000000000000000
Margins.Right = 100.000000000000000000
Position.X = 1955.000000000000000000
Width = 660.000000000000000000
object Label1: TLabel
Align = alTop
AutoSize = True
Height = 40.000000000000000000
Margins.Left = 10.000000000000000000
Margins.Bottom = 5.000000000000000000
Position.X = 10.000000000000000000
StyleLookup = 'pagesubheaderlabel'
Text = 'Group Title: 4'
Width = 165.000000000000000000
WordWrap = False
end
object ListBox1: TListBox
Align = alClient
Height = 855.000000000000000000
StyleLookup = 'collectionlistbox'
TabOrder = 1
Width = 660.000000000000000000
DefaultItemStyles.ItemStyle = ''
DefaultItemStyles.GroupHeaderStyle = ''
DefaultItemStyles.GroupFooterStyle = ''
end
end
end
end
object StyleBook2: TStyleBook
Left = 632
Top = 544
ResourcesBin = {...}
end
object PrototypeBindSource1: TPrototypeBindSource
AutoActivate = True
AutoPost = False
FieldDefs = <
item
Name = 'ContactBitmapL1'
FieldType = ftBitmap
Generator = 'ContactBitmapsL'
ReadOnly = False
end
item
Name = 'ContactName1'
Generator = 'ContactNames'
ReadOnly = False
end
item
Name = 'IntField1'
FieldType = ftInteger
Generator = 'Integers'
ReadOnly = False
end>
ScopeMappings = <>
Left = 1288
Top = 456
end
object BindingsList1: TBindingsList
Methods = <>
OutputConverters = <>
Left = 20
Top = 5
object LinkFillControlToField1: TLinkFillControlToField
Category = 'Quick Bindings'
Control = ListBox4
Track = True
FillDataSource = PrototypeBindSource1
FillDisplayFieldName = 'ContactName1'
AutoFill = True
BufferCount = -1
AutoBufferCount = False
ListItemStyle = 'MetropolisUI'
FillExpressions = <
item
SourceMemberName = 'ContactBitmapL1'
ControlMemberName = 'Icon'
end
item
SourceMemberName = 'IntField1'
ControlMemberName = 'SubTitle'
end>
FillHeaderExpressions = <>
FillBreakGroups = <>
end
object LinkFillControlToField2: TLinkFillControlToField
Category = 'Quick Bindings'
Control = ListBox1
Track = True
FillDataSource = PrototypeBindSource2
FillDisplayFieldName = 'ContactName1'
AutoFill = True
BufferCount = -1
AutoBufferCount = False
ListItemStyle = 'MetropolisUI'
FillExpressions = <
item
SourceMemberName = 'FloatField1'
ControlMemberName = 'SubTitle'
end
item
SourceMemberName = 'ContactBitmap1'
ControlMemberName = 'Icon'
end>
FillHeaderExpressions = <>
FillBreakGroups = <>
end
end
object PrototypeBindSource2: TPrototypeBindSource
AutoActivate = True
AutoPost = False
FieldDefs = <
item
Name = 'ContactBitmap1'
FieldType = ftBitmap
Generator = 'ContactBitmaps'
ReadOnly = False
end
item
Name = 'ContactName1'
Generator = 'ContactNames'
ReadOnly = False
end
item
Name = 'FloatField1'
FieldType = ftSingle
Generator = 'Floats'
ReadOnly = False
end>
ScopeMappings = <>
Left = 1232
Top = 448
end
end
文件上添加“db”角色
e.g。
production.rb
如果/config/deploy
和roles: %w{web app db}
迁移之间存在差异,也可以使用capistrano迁移任务。您可以做的是从current_path
内部删除迁移,然后部署然后迁移。