lib/knj/knjdb/drivers/sqlite3/knjdb_sqlite3_tables.rb in knjrbfw-0.0.45 vs lib/knj/knjdb/drivers/sqlite3/knjdb_sqlite3_tables.rb in knjrbfw-0.0.46
- old
+ new
@@ -111,16 +111,28 @@
def maxlength
return @data[:maxlength]
end
+ #Drops the table from the database.
def drop
- sql = "DROP TABLE `#{self.name}`"
- @db.query(sql)
+ raise "Cant drop native table: '#{self.name}'." if self.native?
+ @db.query("DROP TABLE `#{self.name}`")
end
+ #Returns true if the table is safe to drop.
+ def native?
+ return true if self.name.to_s == "sqlite_sequence"
+ return false
+ end
+
def optimize
raise "stub!"
+ end
+
+ def rename(newname)
+ self.clone(newname)
+ self.drop
end
def truncate
@db.query("DELETE FROM `#{self.name}` WHERE 1=1")
return nil
\ No newline at end of file