Skip to content

Commit 31e3912

Browse files
author
Matt Zukowski
committed
added config option to disable automatic migrations
1 parent ea80f0b commit 31e3912

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

lib/casserver/server.rb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -251,13 +251,15 @@ def self.init_database!
251251
#CASServer::Model::Base.establish_connection(config[:database])
252252
ActiveRecord::Base.establish_connection(config[:database])
253253

254-
print_cli_message "Running migrations to make sure your database schema is up to date..."
255-
prev_db_log = ActiveRecord::Base.logger
256-
ActiveRecord::Base.logger = Logger.new(STDOUT)
257-
ActiveRecord::Migration.verbose = true
258-
ActiveRecord::Migrator.migrate(File.dirname(__FILE__) + "/../../db/migrate")
259-
ActiveRecord::Base.logger = prev_db_log
260-
print_cli_message "Your database is now up to date."
254+
unless config[:disable_auto_migrations]
255+
print_cli_message "Running migrations to make sure your database schema is up to date..."
256+
prev_db_log = ActiveRecord::Base.logger
257+
ActiveRecord::Base.logger = Logger.new(STDOUT)
258+
ActiveRecord::Migration.verbose = true
259+
ActiveRecord::Migrator.migrate(File.dirname(__FILE__) + "/../../db/migrate")
260+
ActiveRecord::Base.logger = prev_db_log
261+
print_cli_message "Your database is now up to date."
262+
end
261263
end
262264

263265
configure do

resources/config.example.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,12 @@ database:
203203
# dbfile: /var/lib/casserver.db
204204

205205

206+
# By default RubyCAS-Server will run migrations at every startup to ensure
207+
# that its database schema is up-to-date. To disable this behaviour set
208+
# the following option to true:
209+
210+
#disable_auto_migrations: true
211+
206212
##### AUTHENTICATION ###########################################################
207213

208214
# Configure how username/passwords are validated.

0 commit comments

Comments
 (0)