Index: de.wigbels.ruby/contact/db/migrate/001_create_contacts.rb
===================================================================
--- de.wigbels.ruby/contact/db/migrate/001_create_contacts.rb	(revision 7b7d827c4fbf1c46a6aab6ad9e1ae735e3bdb79d)
+++ de.wigbels.ruby/contact/db/migrate/001_create_contacts.rb	(revision 7b7d827c4fbf1c46a6aab6ad9e1ae735e3bdb79d)
@@ -0,0 +1,14 @@
+class CreateContacts < ActiveRecord::Migration
+  def self.up
+    create_table :contacts do |t|
+      t.column :name,   :string
+      t.column :email,  :string
+      t.column :url,    :string
+      t.column :free_text,  :text
+    end
+  end
+
+  def self.down
+    drop_table :contacts
+  end
+end
Index: de.wigbels.ruby/contact/db/migrate/002_create_contactgroups.rb
===================================================================
--- de.wigbels.ruby/contact/db/migrate/002_create_contactgroups.rb	(revision 7b7d827c4fbf1c46a6aab6ad9e1ae735e3bdb79d)
+++ de.wigbels.ruby/contact/db/migrate/002_create_contactgroups.rb	(revision 7b7d827c4fbf1c46a6aab6ad9e1ae735e3bdb79d)
@@ -0,0 +1,16 @@
+class CreateContactgroups < ActiveRecord::Migration
+  def self.up
+    create_table :contactgroups do |t|
+      t.column :groupname,   :string
+      t.column :contact_id, :integer, :null => false
+    end
+    
+    execute "alter table contactgroups add constraint fk_contactgroups_contacts
+foreign key (contact_id) references contacts(id)"
+    
+  end
+  
+  def self.down
+    drop_table :contactgroups
+  end
+end
Index: de.wigbels.ruby/contact/db/migrate/003_change_reference_contact_contactgroup.rb
===================================================================
--- de.wigbels.ruby/contact/db/migrate/003_change_reference_contact_contactgroup.rb	(revision 7b7d827c4fbf1c46a6aab6ad9e1ae735e3bdb79d)
+++ de.wigbels.ruby/contact/db/migrate/003_change_reference_contact_contactgroup.rb	(revision 7b7d827c4fbf1c46a6aab6ad9e1ae735e3bdb79d)
@@ -0,0 +1,13 @@
+class ChangeReferenceContactContactgroup < ActiveRecord::Migration
+  def self.up
+    # move the reference between contacts..contactgroups the other way round
+    execute "alter table contactgroups drop foreign key fk_contactgroups_contacts"
+    remove_column :contactgroups, :contact_id
+    
+    add_column :contacts, :contactgroup_id, :integer, :null => false
+    execute "alter table contacts add constraint fk_contacts_contactgroups foreign key (contactgroup_id) references contactgroups(id)"
+  end
+
+  def self.down
+  end
+end
Index: de.wigbels.ruby/contact/db/migrate/004_contact_surename.rb
===================================================================
--- de.wigbels.ruby/contact/db/migrate/004_contact_surename.rb	(revision 7b7d827c4fbf1c46a6aab6ad9e1ae735e3bdb79d)
+++ de.wigbels.ruby/contact/db/migrate/004_contact_surename.rb	(revision 7b7d827c4fbf1c46a6aab6ad9e1ae735e3bdb79d)
@@ -0,0 +1,8 @@
+class ContactSurename < ActiveRecord::Migration
+  def self.up
+    add_column :contacts, :surename, :string
+  end
+  
+  def self.down
+  end
+end
Index: de.wigbels.ruby/contact/db/migrate/005_contact_surname.rb
===================================================================
--- de.wigbels.ruby/contact/db/migrate/005_contact_surname.rb	(revision 7b7d827c4fbf1c46a6aab6ad9e1ae735e3bdb79d)
+++ de.wigbels.ruby/contact/db/migrate/005_contact_surname.rb	(revision 7b7d827c4fbf1c46a6aab6ad9e1ae735e3bdb79d)
@@ -0,0 +1,8 @@
+class ContactSurname < ActiveRecord::Migration
+  def self.up
+    rename_column :contacts, :surename, :surname 
+  end
+  
+  def self.down
+  end
+end
Index: de.wigbels.ruby/contact/db/migrate/006_contact_newname.rb
===================================================================
--- de.wigbels.ruby/contact/db/migrate/006_contact_newname.rb	(revision 7b7d827c4fbf1c46a6aab6ad9e1ae735e3bdb79d)
+++ de.wigbels.ruby/contact/db/migrate/006_contact_newname.rb	(revision 7b7d827c4fbf1c46a6aab6ad9e1ae735e3bdb79d)
@@ -0,0 +1,8 @@
+class ContactNewname < ActiveRecord::Migration
+  def self.up
+      add_column :contacts, :newname, :string
+  end
+
+  def self.down
+  end
+end
Index: de.wigbels.ruby/contact/db/migrate/007_add_indizes.rb
===================================================================
--- de.wigbels.ruby/contact/db/migrate/007_add_indizes.rb	(revision 7b7d827c4fbf1c46a6aab6ad9e1ae735e3bdb79d)
+++ de.wigbels.ruby/contact/db/migrate/007_add_indizes.rb	(revision 7b7d827c4fbf1c46a6aab6ad9e1ae735e3bdb79d)
@@ -0,0 +1,10 @@
+class AddIndizes < ActiveRecord::Migration
+  def self.up
+    add_index :contacts, :name
+    add_index :contacts, :id, :unique => true
+    add_index :contactgroups, :id, :unique => true
+  end
+
+  def self.down
+  end
+end
Index: de.wigbels.ruby/contact/db/migrate/008_drop_indizes.rb
===================================================================
--- de.wigbels.ruby/contact/db/migrate/008_drop_indizes.rb	(revision 7b7d827c4fbf1c46a6aab6ad9e1ae735e3bdb79d)
+++ de.wigbels.ruby/contact/db/migrate/008_drop_indizes.rb	(revision 7b7d827c4fbf1c46a6aab6ad9e1ae735e3bdb79d)
@@ -0,0 +1,9 @@
+class DropIndizes < ActiveRecord::Migration
+  def self.up
+    remove_index :contacts, :id
+    remove_index :contactgroups, :id
+  end
+  
+  def self.down
+  end
+end
