simple_mysql_partitioning 0.2.0 → 0.2.1
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0067c6333d5d6157c271f4e00d5c7480ac3e998b6ec81a3d3b49a0645f636a5b
|
4
|
+
data.tar.gz: 2e60c8ca0fe8ba635363e0492b80d5ef6622f145ef97b987f23ecf4fe099b361
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dba59fa8e74fc27264a8113cf67d9221bae38c8d5cf0a4b98442bea9c5a1733aa044a54085dd51b8d844ce9a130ab2e8cc87bf0879228bfb79c98adf0054820f
|
7
|
+
data.tar.gz: 30b894f9f6480418384e2b5bc42b593d4fe3f85cb46ba6a779f43c31c96e78392e20c63a0f70c4abb71b6aa7cbcea90d2911ff68146ce2e398d3c1a28717b4df
|
@@ -11,13 +11,14 @@ module SimpleMySQLPartitioning
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
def reorganize(pairs_name_with_value, reorganize_partition_name)
|
14
|
+
def reorganize(pairs_name_with_value, reorganize_partition_name, reorganize_partition_value = 'MAXVALUE')
|
15
15
|
pairs_name_with_value.map do |pair|
|
16
16
|
klass.connection.execute(
|
17
17
|
SQL.reorganize_sql(
|
18
18
|
table_name,
|
19
19
|
pair.first, pair.last,
|
20
|
-
reorganize_partition_name
|
20
|
+
reorganize_partition_name,
|
21
|
+
reorganize_partition_value
|
21
22
|
)
|
22
23
|
)
|
23
24
|
end
|
@@ -16,20 +16,26 @@ module SimpleMySQLPartitioning
|
|
16
16
|
|
17
17
|
def add_sql(table_name, partition_name, value)
|
18
18
|
"ALTER TABLE #{table_name}
|
19
|
-
ADD PARTITION ( PARTITION #{partition_name} VALUES LESS THAN
|
19
|
+
ADD PARTITION ( PARTITION #{partition_name} VALUES LESS THAN #{less_than(value)});"
|
20
20
|
end
|
21
21
|
|
22
22
|
def reorganize_sql(table_name, partition_name, value, reorganize_partition_name, max_value = 'MAXVALUE')
|
23
23
|
"ALTER TABLE #{table_name}
|
24
24
|
REORGANIZE PARTITION #{reorganize_partition_name} INTO (
|
25
25
|
PARTITION #{partition_name} VALUES LESS THAN ('#{value}'),
|
26
|
-
PARTITION #{reorganize_partition_name} VALUES LESS THAN #{max_value}
|
26
|
+
PARTITION #{reorganize_partition_name} VALUES LESS THAN #{less_than(max_value)}
|
27
27
|
);"
|
28
28
|
end
|
29
29
|
|
30
30
|
def parge_sql(table_name, partition_name)
|
31
31
|
"ALTER TABLE #{table_name} DROP PARTITION #{partition_name};"
|
32
32
|
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def less_than(value)
|
37
|
+
value == 'MAXVALUE' ? value : "('#{value}')"
|
38
|
+
end
|
33
39
|
end
|
34
40
|
end
|
35
41
|
end
|