lib/og/backends/mysql.rb in og-0.6.0 vs lib/og/backends/mysql.rb in og-0.7.0
- old
+ new
@@ -1,11 +1,11 @@
# code:
# * George Moschovitis <gm@navel.gr>
# * Elias Athanasopoulos <elathan@navel.gr>
#
# (c) 2004 Navel, all rights reserved.
-# $Id: mysql.rb 185 2004-12-10 13:29:09Z gmosx $
+# $Id: mysql.rb 194 2004-12-20 20:23:57Z gmosx $
require "mysql"
require "og/backend"
@@ -261,25 +261,11 @@
# Create the managed object table. The properties of the
# object are mapped to the table columns. Additional sql relations
# and constrains are created (indicices, sequences, etc).
#
def create_table(klass)
- fields = []
-
- klass.__props.each do |p|
- klass.sql_index(p.symbol) if p.meta[:sql_index]
-
- field = "#{p.symbol}"
-
- if p.meta and p.meta[:sql]
- field << " #{p.meta[:sql]}"
- else
- field << " #{TYPEMAP[p.klass]}"
- end
-
- fields << field
- end
+ fields = create_fields(klass, TYPEMAP)
sql = "CREATE TABLE #{klass::DBTABLE} (#{fields.join(', ')}"
# Create table constrains
@@ -324,10 +310,10 @@
# is not managed yet.
join_table = "#{Og::Utils.join_table(klass, join_class)}"
join_src = "#{Og::Utils.encode(klass)}_oid"
join_dst = "#{Og::Utils.encode(join_class)}_oid"
begin
- exec "CREATE TABLE #{join_table} ( key1 integer, key2 integer )"
+ exec "CREATE TABLE #{join_table} ( key1 integer NOT NULL, key2 integer NOT NULL )"
exec "CREATE INDEX #{join_table}_key1_idx ON #{join_table} (key1)"
exec "CREATE INDEX #{join_table}_key2_idx ON #{join_table} (key2)"
rescue => ex
if ex.errno == 1050 # table already exists.
$log.debug "Join table already exists" if $DBG