muck-services 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/db/migrate/20090703175825_denormalize_entries_subjects.rb +4 -1
- data/db/migrate/20090717175825_normalize_entries_subjects.rb +7 -1
- data/muck-services.gemspec +1 -1
- data/test/rails_root/db/migrate/20090703175825_denormalize_entries_subjects.rb +4 -1
- data/test/rails_root/db/migrate/20090717175825_normalize_entries_subjects.rb +7 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
@@ -11,13 +11,16 @@ class DenormalizeEntriesSubjects < ActiveRecord::Migration
|
|
11
11
|
|
12
12
|
if adapter == 'mysql'
|
13
13
|
execute "ALTER TABLE entries_subjects DROP PRIMARY KEY, ADD PRIMARY KEY USING BTREE(subject_id, language_id, grain_size, entry_id);"
|
14
|
+
execute "UPDATE entries_subjects AS es INNER JOIN entries AS e ON e.id = es.entry_id SET es.language_id = e.language_id, es.grain_size = e.grain_size"
|
14
15
|
elsif adapter == 'postgresql'
|
15
16
|
execute "DROP INDEX entries_subjects_subject_id_entry_id"
|
16
17
|
execute "CREATE UNIQUE INDEX entries_subjects_subject_id_entry_id ON entries_subjects USING btree(subject_id, language_id, grain_size, entry_id); "
|
17
18
|
execute "ALTER TABLE entries_subjects CLUSTER ON entries_subjects_subject_id_entry_id; "
|
19
|
+
execute "UPDATE entries_subjects es SET language_id = e.language_id, grain_size = e.grain_size FROM entries e WHERE es.entry_id = e.id"
|
20
|
+
else
|
21
|
+
raise 'Migration not implemented for this DB adapter'
|
18
22
|
end
|
19
23
|
|
20
|
-
execute "UPDATE entries_subjects AS es INNER JOIN entries AS e ON e.id = es.entry_id SET es.language_id = e.language_id, es.grain_size = e.grain_size"
|
21
24
|
end
|
22
25
|
|
23
26
|
def self.down
|
@@ -10,6 +10,8 @@ class NormalizeEntriesSubjects < ActiveRecord::Migration
|
|
10
10
|
execute "DROP INDEX entries_subjects_subject_id_entry_id"
|
11
11
|
execute "CREATE UNIQUE INDEX entries_subjects_subject_id_entry_id ON entries_subjects USING btree(subject_id, entry_id); "
|
12
12
|
execute "ALTER TABLE entries_subjects CLUSTER ON entries_subjects_subject_id_entry_id; "
|
13
|
+
else
|
14
|
+
raise 'Migration not implemented for this data adapter'
|
13
15
|
end
|
14
16
|
|
15
17
|
remove_column :entries_subjects, :language_id
|
@@ -30,12 +32,16 @@ class NormalizeEntriesSubjects < ActiveRecord::Migration
|
|
30
32
|
|
31
33
|
if adapter == 'mysql'
|
32
34
|
execute "ALTER TABLE entries_subjects DROP PRIMARY KEY, ADD PRIMARY KEY USING BTREE(subject_id, language_id, grain_size, entry_id);"
|
35
|
+
execute "UPDATE entries_subjects AS es INNER JOIN entries AS e ON e.id = es.entry_id SET es.language_id = e.language_id, es.grain_size = e.grain_size"
|
33
36
|
elsif adapter == 'postgresql'
|
34
37
|
execute "DROP INDEX entries_subjects_subject_id_entry_id"
|
35
38
|
execute "CREATE UNIQUE INDEX entries_subjects_subject_id_entry_id ON entries_subjects USING btree(subject_id, language_id, grain_size, entry_id); "
|
36
39
|
execute "ALTER TABLE entries_subjects CLUSTER ON entries_subjects_subject_id_entry_id; "
|
40
|
+
execute "UPDATE entries_subjects es SET language_id = e.language_id, grain_size = e.grain_size FROM entries e WHERE es.entry_id = e.id"
|
41
|
+
else
|
42
|
+
raise 'Migration not implemented for this data adapter'
|
37
43
|
end
|
38
44
|
|
39
|
-
|
45
|
+
|
40
46
|
end
|
41
47
|
end
|
data/muck-services.gemspec
CHANGED
@@ -11,13 +11,16 @@ class DenormalizeEntriesSubjects < ActiveRecord::Migration
|
|
11
11
|
|
12
12
|
if adapter == 'mysql'
|
13
13
|
execute "ALTER TABLE entries_subjects DROP PRIMARY KEY, ADD PRIMARY KEY USING BTREE(subject_id, language_id, grain_size, entry_id);"
|
14
|
+
execute "UPDATE entries_subjects AS es INNER JOIN entries AS e ON e.id = es.entry_id SET es.language_id = e.language_id, es.grain_size = e.grain_size"
|
14
15
|
elsif adapter == 'postgresql'
|
15
16
|
execute "DROP INDEX entries_subjects_subject_id_entry_id"
|
16
17
|
execute "CREATE UNIQUE INDEX entries_subjects_subject_id_entry_id ON entries_subjects USING btree(subject_id, language_id, grain_size, entry_id); "
|
17
18
|
execute "ALTER TABLE entries_subjects CLUSTER ON entries_subjects_subject_id_entry_id; "
|
19
|
+
execute "UPDATE entries_subjects es SET language_id = e.language_id, grain_size = e.grain_size FROM entries e WHERE es.entry_id = e.id"
|
20
|
+
else
|
21
|
+
raise 'Migration not implemented for this DB adapter'
|
18
22
|
end
|
19
23
|
|
20
|
-
execute "UPDATE entries_subjects AS es INNER JOIN entries AS e ON e.id = es.entry_id SET es.language_id = e.language_id, es.grain_size = e.grain_size"
|
21
24
|
end
|
22
25
|
|
23
26
|
def self.down
|
@@ -10,6 +10,8 @@ class NormalizeEntriesSubjects < ActiveRecord::Migration
|
|
10
10
|
execute "DROP INDEX entries_subjects_subject_id_entry_id"
|
11
11
|
execute "CREATE UNIQUE INDEX entries_subjects_subject_id_entry_id ON entries_subjects USING btree(subject_id, entry_id); "
|
12
12
|
execute "ALTER TABLE entries_subjects CLUSTER ON entries_subjects_subject_id_entry_id; "
|
13
|
+
else
|
14
|
+
raise 'Migration not implemented for this data adapter'
|
13
15
|
end
|
14
16
|
|
15
17
|
remove_column :entries_subjects, :language_id
|
@@ -30,12 +32,16 @@ class NormalizeEntriesSubjects < ActiveRecord::Migration
|
|
30
32
|
|
31
33
|
if adapter == 'mysql'
|
32
34
|
execute "ALTER TABLE entries_subjects DROP PRIMARY KEY, ADD PRIMARY KEY USING BTREE(subject_id, language_id, grain_size, entry_id);"
|
35
|
+
execute "UPDATE entries_subjects AS es INNER JOIN entries AS e ON e.id = es.entry_id SET es.language_id = e.language_id, es.grain_size = e.grain_size"
|
33
36
|
elsif adapter == 'postgresql'
|
34
37
|
execute "DROP INDEX entries_subjects_subject_id_entry_id"
|
35
38
|
execute "CREATE UNIQUE INDEX entries_subjects_subject_id_entry_id ON entries_subjects USING btree(subject_id, language_id, grain_size, entry_id); "
|
36
39
|
execute "ALTER TABLE entries_subjects CLUSTER ON entries_subjects_subject_id_entry_id; "
|
40
|
+
execute "UPDATE entries_subjects es SET language_id = e.language_id, grain_size = e.grain_size FROM entries e WHERE es.entry_id = e.id"
|
41
|
+
else
|
42
|
+
raise 'Migration not implemented for this data adapter'
|
37
43
|
end
|
38
44
|
|
39
|
-
|
45
|
+
|
40
46
|
end
|
41
47
|
end
|