Skip to content

Add functionality for db:create #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 27, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion lib/active_record/tasks/sqlserver_database_tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,23 @@ def initialize(configuration)
@configuration = configuration
end

def drop
def create(master_established = false)
establish_master_connection unless master_established
connection.create_database configuration['database']
establish_connection configuration

rescue ActiveRecord::StatementInvalid => error
if /Database .* already exists/ === error.message
raise DatabaseAlreadyExists
else
raise
end
end

def drop(master_established = false)
establish_master_connection unless master_established
connection.drop_database configuration['database']
establish_connection configuration
end

def purge
Expand All @@ -36,6 +50,12 @@ def creation_options
end
end

def establish_master_connection
establish_connection configuration.merge(
'database' => 'master'
)
end

ActiveRecord::Tasks::DatabaseTasks.register_task(/sqlserver/, ActiveRecord::Tasks::SQLServerDatabaseTasks)
end
end
Expand Down
Empty file modified test/profile/query_plan_complex.rb
100755 → 100644
Empty file.
Empty file modified test/profile/query_plan_simple.rb
100755 → 100644
Empty file.