Class: Ardb::Adapter::Sqlite
- Inherits:
-
Base
- Object
- Base
- Ardb::Adapter::Sqlite
show all
- Defined in:
- lib/ardb/adapter/sqlite.rb
Instance Attribute Summary
Attributes inherited from Base
#config_settings, #database, #ruby_schema_path, #schema_format, #sql_schema_path
Instance Method Summary
collapse
Methods inherited from Base
#==, #drop_tables, #dump_ruby_schema, #dump_schema, #dump_sql_schema, #foreign_key_add_sql, #foreign_key_drop_sql, #initialize, #load_ruby_schema, #load_schema, #load_sql_schema, #migrate_db
Instance Method Details
#create_db ⇒ Object
24
25
26
27
28
|
# File 'lib/ardb/adapter/sqlite.rb', line 24
def create_db
validate!
FileUtils.mkdir_p File.dirname(self.db_file_path)
ActiveRecord::Base.establish_connection(self.config_settings)
end
|
#db_file_path ⇒ Object
10
11
12
13
14
15
16
|
# File 'lib/ardb/adapter/sqlite.rb', line 10
def db_file_path
if (path = Pathname.new(self.database)).absolute?
path.to_s
else
Ardb.config.root_path.join(path).to_s
end
end
|
#drop_db ⇒ Object
30
31
32
|
# File 'lib/ardb/adapter/sqlite.rb', line 30
def drop_db
FileUtils.rm(self.db_file_path) if File.exist?(self.db_file_path)
end
|
#validate! ⇒ Object
18
19
20
21
22
|
# File 'lib/ardb/adapter/sqlite.rb', line 18
def validate!
if File.exist?(self.db_file_path)
raise Ardb::Runner::CmdError, "#{self.database} already exists"
end
end
|