class Lightning::DatabaseAction

Public Class Methods

create() click to toggle source
# File lib/framework/db.rb, line 72
def self.create
    Database.enable_logging
    Database.connect

    ActiveRecord::Base.connection.create_database(
        DatabaseDetails.database_name,
        charset: DatabaseDetails.default_charset
    )
end
drop() click to toggle source
# File lib/framework/db.rb, line 82
def self.drop
    Database.enable_logging
    Database.connect_and_select

    ActiveRecord::Base.connection.drop_database(
        DatabaseDetails.database_name
    )
end
dump_schema() click to toggle source
# File lib/framework/db.rb, line 91
def self.dump_schema
    Database.enable_logging
    Database.connect_and_select

    require 'active_record/schema_dumper'
    File.open('db/schema.rb', 'w:utf-8') do |file|
        ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, file)
    end
end
migrate() click to toggle source
# File lib/framework/db.rb, line 52
def self.migrate
    Database.enable_logging
    Database.connect_and_select

    ActiveRecord::Base.connection.migration_context.migrate

    # Use this only when we have a task for loading from this schema.
    # Rake::Task["db:dump_schema"].invoke
end
rollback() click to toggle source
# File lib/framework/db.rb, line 62
def self.rollback
    Database.enable_logging
    Database.connect_and_select

    ActiveRecord::Base.connection.migration_context.rollback

    # Use this only when we have a task for loading from this schema.
    # Rake::Task["db:dump_schema"].invoke
end