Module: Six::Dbmanager
- Defined in:
- lib/six-updater-web/vendor/plugins/six-db_manager/lib/six/dbmanager.rb
Defined Under Namespace
Modules: Migrate
Constant Summary collapse
- FOLDER =
/(.*)\/(.*)/
Class Method Summary collapse
- .capture_stdout ⇒ Object
- .check ⇒ Object
- .cmd(command) ⇒ Object
- .create ⇒ Object
- .drop ⇒ Object
- .load_data ⇒ Object
- .load_me(opts = {}) ⇒ Object
- .load_system ⇒ Object
- .load_test ⇒ Object
- .logger ⇒ Object
- .migrate_data ⇒ Object
- .migrate_system ⇒ Object
- .new ⇒ Object
- .reload_data ⇒ Object
- .reload_full ⇒ Object
- .reload_system ⇒ Object
Class Method Details
.capture_stdout ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/six-updater-web/vendor/plugins/six-db_manager/lib/six/dbmanager.rb', line 48 def capture_stdout s = StringIO.new oldstdout, oldstderr = $stdout, $stderr $stdout, $stderr = s, s yield logger.debug s.string s.string ensure $stdout, $stderr = oldstdout, oldstderr end |
.check ⇒ Object
167 168 169 170 171 172 173 174 175 176 |
# File 'lib/six-updater-web/vendor/plugins/six-db_manager/lib/six/dbmanager.rb', line 167 def check g = Goldberg::SiteController.find_by_name("queryservers") unless g g = Goldberg::SiteController.new g.name = "queryservers" g. = 1 g.save Goldberg::Role.rebuild_cache end end |
.cmd(command) ⇒ Object
59 60 61 |
# File 'lib/six-updater-web/vendor/plugins/six-db_manager/lib/six/dbmanager.rb', line 59 def cmd(command) capture_stdout {Rake.application[command].invoke} end |
.create ⇒ Object
70 71 72 73 74 75 |
# File 'lib/six-updater-web/vendor/plugins/six-db_manager/lib/six/dbmanager.rb', line 70 def create results = "" logger.debug "CREATE" results += cmd 'db:create' results end |
.drop ⇒ Object
63 64 65 66 67 68 |
# File 'lib/six-updater-web/vendor/plugins/six-db_manager/lib/six/dbmanager.rb', line 63 def drop results = "" logger.debug "DROP" results += cmd 'db:drop' results end |
.load_data ⇒ Object
157 158 159 |
# File 'lib/six-updater-web/vendor/plugins/six-db_manager/lib/six/dbmanager.rb', line 157 def load_data load_me :selection => :data end |
.load_me(opts = {}) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/six-updater-web/vendor/plugins/six-db_manager/lib/six/dbmanager.rb', line 95 def load_me(opts = {}) defopts = {} defopts[:selection] = :all defopts[:folder] = 'vendor/plugins/six-db_manager/db' opts = defopts.merge opts logger.debug "LOAD #{opts}" results = "" list = [] run = true old = if ENV['FIXTURES'] ENV['FIXTURES'].clone else nil end old2 = if ENV['FIXTURES_PATH'] ENV['FIXTURES_PATH'].clone else nil end unless opts[:selection] == :all logger.debug "Found specific selection" Dir[File.join(RAILS_ROOT, opts[:folder], '*.yml')].each do |path| path[FOLDER] folder, file = $1, $2 ok = true case opts[:selection] when :system list << file if file[/\Agoldberg_/] when :data list << file unless file[/\Agoldberg_/] end end if list.size > 0 joined = list.join(',') logger.debug "list: #{joined}" ENV['FIXTURES'] = joined else logger.debug "Nothing to load!" run = false end end if run ENV['FIXTURES_PATH'] = opts[:folder] logger.debug "path: #{opts[:folder]}" results += cmd 'db:fixtures:load' ENV['FIXTURES'] = old ENV['FIXTURES_PATH'] = old2 end results end |
.load_system ⇒ Object
161 162 163 164 165 |
# File 'lib/six-updater-web/vendor/plugins/six-db_manager/lib/six/dbmanager.rb', line 161 def load_system r = load_me :selection => :system Goldberg::Role.rebuild_cache r end |
.load_test ⇒ Object
153 154 155 |
# File 'lib/six-updater-web/vendor/plugins/six-db_manager/lib/six/dbmanager.rb', line 153 def load_test cmd 'db:fixtures:load' end |
.logger ⇒ Object
44 45 46 |
# File 'lib/six-updater-web/vendor/plugins/six-db_manager/lib/six/dbmanager.rb', line 44 def logger ActionController::Base.logger end |
.migrate_data ⇒ Object
77 78 79 80 81 82 |
# File 'lib/six-updater-web/vendor/plugins/six-db_manager/lib/six/dbmanager.rb', line 77 def migrate_data results = "" logger.debug "MIGRATE data" results += cmd 'db:migrate' results end |
.migrate_system ⇒ Object
84 85 86 87 88 89 90 91 92 93 |
# File 'lib/six-updater-web/vendor/plugins/six-db_manager/lib/six/dbmanager.rb', line 84 def migrate_system logger.debug "MIGRATE system" results = "" begin results += cmd 'goldberg:migrate' rescue end results += cmd 'goldberg:migrate' results end |
.new ⇒ Object
200 201 202 203 204 205 206 |
# File 'lib/six-updater-web/vendor/plugins/six-db_manager/lib/six/dbmanager.rb', line 200 def new results = "" results += drop results += create results += reload_full results end |
.reload_data ⇒ Object
185 186 187 188 189 190 |
# File 'lib/six-updater-web/vendor/plugins/six-db_manager/lib/six/dbmanager.rb', line 185 def reload_data results = "" results += migrate_data results += load_data results end |
.reload_full ⇒ Object
192 193 194 195 196 197 198 |
# File 'lib/six-updater-web/vendor/plugins/six-db_manager/lib/six/dbmanager.rb', line 192 def reload_full results = "" results += migrate_data results += migrate_system results += load_me results end |
.reload_system ⇒ Object
178 179 180 181 182 183 |
# File 'lib/six-updater-web/vendor/plugins/six-db_manager/lib/six/dbmanager.rb', line 178 def reload_system results = "" results += migrate_system results += load_system results end |