Class: Baza::Driver::Mysql::Database
- Inherits:
-
Baza::Database
- Object
- Baza::Database
- Baza::Driver::Mysql::Database
- Defined in:
- lib/baza/driver/mysql/database.rb
Direct Known Subclasses
Baza::Driver::Mysql2::Database, Baza::Driver::MysqlJava::Database
Instance Attribute Summary
Attributes inherited from Baza::Database
Instance Method Summary collapse
-
#create_table(name, columns:, indexes: nil, return_sql: false, temp: false) ⇒ Object
Creates a new table by the given name and data.
- #drop ⇒ Object
- #save! ⇒ Object
Methods inherited from Baza::Database
#import_file!, #initialize, #name_changed?, #name_was, #table, #table_exists?, #tables, #to_param, #use
Methods included from Baza::DatabaseModelFunctionality
Constructor Details
This class inherits a constructor from Baza::Database
Instance Method Details
#create_table(name, columns:, indexes: nil, return_sql: false, temp: false) ⇒ Object
Creates a new table by the given name and data.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/baza/driver/mysql/database.rb', line 14 def create_table(name, columns:, indexes: nil, return_sql: false, temp: false) raise "No columns was given for '#{name}'." if !columns || columns.empty? sql = Baza::Driver::Mysql::Sql::CreateTable .new( columns: columns, indexes: indexes, name: name, temporary: temp ) .sql return sql if return_sql use do sql.each do |sql_i| @db.query(sql_i) end end end |
#drop ⇒ Object
7 8 9 10 11 |
# File 'lib/baza/driver/mysql/database.rb', line 7 def drop sql = "DROP DATABASE #{@db.quote_database(name)}" @db.query(sql) self end |
#save! ⇒ Object
2 3 4 5 |
# File 'lib/baza/driver/mysql/database.rb', line 2 def save! rename(name) unless name.to_s == name_was self end |