dbdiff 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/CHANGELOG +6 -0
  2. data/LICENSE +58 -0
  3. data/README +29 -0
  4. data/lib/dbdiff/column.rb +69 -0
  5. data/lib/dbdiff/database.rb +169 -0
  6. data/lib/dbdiff/delta.rb +266 -0
  7. data/lib/dbdiff/foreign_key.rb +68 -0
  8. data/lib/dbdiff/key.rb +69 -0
  9. data/lib/dbdiff/row.rb +32 -0
  10. data/lib/dbdiff/table.rb +50 -0
  11. data/lib/dbdiff/table_element.rb +16 -0
  12. data/lib/dbdiff.rb +207 -0
  13. data/test/ai_column/source.sql +10 -0
  14. data/test/ai_column/target.sql +7 -0
  15. data/test/change_pk/source.sql +11 -0
  16. data/test/change_pk/target.sql +8 -0
  17. data/test/column/source.sql +10 -0
  18. data/test/column/target.sql +9 -0
  19. data/test/fk/source.sql +19 -0
  20. data/test/fk/target.sql +20 -0
  21. data/test/key/source.sql +11 -0
  22. data/test/key/target.sql +10 -0
  23. data/test/modify_column/source.sql +9 -0
  24. data/test/modify_column/target.sql +10 -0
  25. data/test/modify_fk/source.sql +20 -0
  26. data/test/modify_fk/target.sql +22 -0
  27. data/test/modify_key_fk/source.sql +19 -0
  28. data/test/modify_key_fk/target.sql +20 -0
  29. data/test/modify_key_fk_ref/source.sql +18 -0
  30. data/test/modify_key_fk_ref/target.sql +20 -0
  31. data/test/modify_row/source.sql +8 -0
  32. data/test/modify_row/target.sql +9 -0
  33. data/test/modify_table/source.sql +8 -0
  34. data/test/modify_table/target.sql +9 -0
  35. data/test/multi_fk/source.sql +22 -0
  36. data/test/multi_fk/target.sql +20 -0
  37. data/test/multi_key/source.sql +11 -0
  38. data/test/multi_key/target.sql +10 -0
  39. data/test/multi_unique_key/source.sql +11 -0
  40. data/test/multi_unique_key/target.sql +10 -0
  41. data/test/row/source.sql +8 -0
  42. data/test/row/target.sql +6 -0
  43. data/test/suite.rb +7 -0
  44. data/test/table/source.sql +9 -0
  45. data/test/table/target.sql +0 -0
  46. data/test/table_fk/source.sql +13 -0
  47. data/test/table_fk/target.sql +20 -0
  48. data/test/table_fk2/source.sql +17 -0
  49. data/test/table_fk2/target.sql +5 -0
  50. data/test/test_column.rb +93 -0
  51. data/test/test_dbdiff.rb +92 -0
  52. data/test/test_foreign_key.rb +136 -0
  53. data/test/test_key.rb +116 -0
  54. data/test/test_row.rb +84 -0
  55. data/test/test_table.rb +30 -0
  56. data/test/unique_key/source.sql +11 -0
  57. data/test/unique_key/target.sql +9 -0
  58. metadata +127 -0
data/test/test_row.rb ADDED
@@ -0,0 +1,84 @@
1
+ require 'dbdiff'
2
+ require 'test/unit'
3
+
4
+ class TestRow < Test::Unit::TestCase
5
+
6
+ def test_load
7
+
8
+ t = DbDiff::Table.new( 'ENGINE' => 'InnoDB', 'TABLE_COLLATION' => 'latin1', 'TABLE_NAME' => 'mytable')
9
+ t.keys << DbDiff::Key.new(t.name,
10
+ 'Key_name' => 'PRIMARY',
11
+ 'Seq_in_index' => '1',
12
+ 'Column_name' => 'id',
13
+ 'Non_unique' => '0'
14
+ )
15
+
16
+ row = DbDiff::Row.new(
17
+ t,
18
+ 'id' => '1',
19
+ 'name' => 'foo',
20
+ 'address' => 'blah'
21
+ )
22
+
23
+ assert(row.name == '1')
24
+ assert(row.data == {'id' => '1', 'name' => 'foo', 'address' => 'blah'})
25
+
26
+ end
27
+
28
+
29
+
30
+ def test_not_equal
31
+ t = DbDiff::Table.new( 'ENGINE' => 'InnoDB', 'TABLE_COLLATION' => 'latin1', 'TABLE_NAME' => 'mytable')
32
+ t.keys << DbDiff::Key.new(t.name,
33
+ 'Key_name' => 'PRIMARY',
34
+ 'Seq_in_index' => '1',
35
+ 'Column_name' => 'id',
36
+ 'Non_unique' => '0'
37
+ )
38
+
39
+ r1 = DbDiff::Row.new(
40
+ t,
41
+ 'id' => '1',
42
+ 'name' => 'foo',
43
+ 'address' => 'blah'
44
+ )
45
+
46
+ r2 = DbDiff::Row.new(
47
+ t,
48
+ 'id' => '2',
49
+ 'name' => 'blah',
50
+ 'address' => 'blah'
51
+ )
52
+
53
+ assert(r1 != r2)
54
+
55
+ end
56
+
57
+ def test_equal
58
+ t = DbDiff::Table.new( 'ENGINE' => 'InnoDB', 'TABLE_COLLATION' => 'latin1', 'TABLE_NAME' => 'mytable')
59
+ t.keys << DbDiff::Key.new(t.name,
60
+ 'Key_name' => 'PRIMARY',
61
+ 'Seq_in_index' => '1',
62
+ 'Column_name' => 'id',
63
+ 'Non_unique' => '0'
64
+ )
65
+
66
+ r1 = DbDiff::Row.new(
67
+ t,
68
+ 'id' => '1',
69
+ 'name' => 'foo',
70
+ 'address' => 'blah'
71
+ )
72
+
73
+ r2 = DbDiff::Row.new(
74
+ t,
75
+ 'id' => '1',
76
+ 'name' => 'foo',
77
+ 'address' => 'blah'
78
+ )
79
+
80
+ assert(r1 == r2)
81
+ end
82
+
83
+ end
84
+
@@ -0,0 +1,30 @@
1
+ require 'dbdiff'
2
+ require 'test/unit'
3
+
4
+ class TestTable < Test::Unit::TestCase
5
+
6
+ def test_load
7
+ t = DbDiff::Table.new( 'ENGINE' => 'InnoDB', 'TABLE_COLLATION' => 'latin1', 'TABLE_NAME' => 'mytable')
8
+
9
+ assert(t.engine == 'InnoDB')
10
+ assert(t.collation == 'latin1')
11
+ assert(t.name == 'mytable')
12
+
13
+ end
14
+
15
+ def test_equal
16
+ t1 = DbDiff::Table.new( 'ENGINE' => 'InnoDB', 'TABLE_COLLATION' => 'latin1', 'TABLE_NAME' => 'mytable')
17
+ t2 = DbDiff::Table.new( 'ENGINE' => 'InnoDB', 'TABLE_COLLATION' => 'latin1', 'TABLE_NAME' => 'mytable')
18
+
19
+ assert(t1 == t2)
20
+ end
21
+
22
+ def test_not_equal
23
+ t1 = DbDiff::Table.new( 'ENGINE' => 'InnoDB', 'TABLE_COLLATION' => 'latin1', 'TABLE_NAME' => 'mytable')
24
+ t2 = DbDiff::Table.new( 'ENGINE' => 'InnoDB', 'TABLE_COLLATION' => 'latin1', 'TABLE_NAME' => 'mytable4')
25
+
26
+ assert(t1 != t2)
27
+ end
28
+
29
+ end
30
+
@@ -0,0 +1,11 @@
1
+ DROP TABLE IF EXISTS `authors`;
2
+
3
+ CREATE TABLE authors (
4
+ `id` int(11) NOT NULL auto_increment,
5
+ `name` char(60) NOT NULL,
6
+ `address1` char(60) NOT NULL,
7
+ unique(name),
8
+ PRIMARY KEY (`id`)
9
+ ) ENGINE=innodb DEFAULT CHARSET=latin1;
10
+
11
+
@@ -0,0 +1,9 @@
1
+
2
+ CREATE TABLE authors (
3
+ `id` int(11) NOT NULL auto_increment,
4
+ `name` char(60) NOT NULL,
5
+ `address1` char(60) NOT NULL,
6
+ PRIMARY KEY (`id`)
7
+ ) ENGINE=innodb DEFAULT CHARSET=latin1;
8
+
9
+
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.0
3
+ specification_version: 1
4
+ name: dbdiff
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.1.0
7
+ date: 2006-09-10 00:00:00 -07:00
8
+ summary: DbDiff performs diffs between two databases and applies changes
9
+ require_paths:
10
+ - lib
11
+ email: ekolve@rubyforge.org
12
+ homepage: dbdiff.rubyforge.org
13
+ rubyforge_project: dbdiff
14
+ description:
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Eric Kolve
31
+ files:
32
+ - test/column
33
+ - test/multi_unique_key
34
+ - test/test_row.rb
35
+ - test/multi_key
36
+ - test/test_key.rb
37
+ - test/multi_fk
38
+ - test/suite.rb
39
+ - test/test_column.rb
40
+ - test/unique_key
41
+ - test/table_fk2
42
+ - test/table_fk
43
+ - test/modify_key_fk
44
+ - test/test_dbdiff.rb
45
+ - test/test_table.rb
46
+ - test/modify_table
47
+ - test/ai_column
48
+ - test/modify_column
49
+ - test/fk
50
+ - test/modify_key_fk_ref
51
+ - test/change_pk
52
+ - test/key
53
+ - test/row
54
+ - test/table
55
+ - test/test_foreign_key.rb
56
+ - test/modify_fk
57
+ - test/modify_row
58
+ - test/column/source.sql
59
+ - test/column/target.sql
60
+ - test/multi_unique_key/source.sql
61
+ - test/multi_unique_key/target.sql
62
+ - test/multi_key/source.sql
63
+ - test/multi_key/target.sql
64
+ - test/multi_fk/source.sql
65
+ - test/multi_fk/target.sql
66
+ - test/unique_key/source.sql
67
+ - test/unique_key/target.sql
68
+ - test/table_fk2/source.sql
69
+ - test/table_fk2/target.sql
70
+ - test/table_fk/source.sql
71
+ - test/table_fk/target.sql
72
+ - test/modify_key_fk/source.sql
73
+ - test/modify_key_fk/target.sql
74
+ - test/modify_table/source.sql
75
+ - test/modify_table/target.sql
76
+ - test/ai_column/source.sql
77
+ - test/ai_column/target.sql
78
+ - test/modify_column/source.sql
79
+ - test/modify_column/target.sql
80
+ - test/fk/source.sql
81
+ - test/fk/target.sql
82
+ - test/modify_key_fk_ref/source.sql
83
+ - test/modify_key_fk_ref/target.sql
84
+ - test/change_pk/source.sql
85
+ - test/change_pk/target.sql
86
+ - test/key/source.sql
87
+ - test/key/target.sql
88
+ - test/row/source.sql
89
+ - test/row/target.sql
90
+ - test/table/source.sql
91
+ - test/table/target.sql
92
+ - test/modify_fk/source.sql
93
+ - test/modify_fk/target.sql
94
+ - test/modify_row/source.sql
95
+ - test/modify_row/target.sql
96
+ - lib/dbdiff.rb
97
+ - lib/dbdiff
98
+ - lib/dbdiff/key.rb
99
+ - lib/dbdiff/row.rb
100
+ - lib/dbdiff/foreign_key.rb
101
+ - lib/dbdiff/database.rb
102
+ - lib/dbdiff/column.rb
103
+ - lib/dbdiff/delta.rb
104
+ - lib/dbdiff/table_element.rb
105
+ - lib/dbdiff/table.rb
106
+ - README
107
+ - CHANGELOG
108
+ - LICENSE
109
+ test_files: []
110
+
111
+ rdoc_options:
112
+ - --main
113
+ - README
114
+ - --title
115
+ - "'DbDiff RDoc'"
116
+ extra_rdoc_files:
117
+ - README
118
+ - CHANGELOG
119
+ - LICENSE
120
+ executables: []
121
+
122
+ extensions: []
123
+
124
+ requirements: []
125
+
126
+ dependencies: []
127
+