pg_partitioner 0.1.0 → 0.2.0

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: ad50f500db988df0b9399ef603c453e2bc9b0ce6d7ce0b125649a59e17790239
4
- data.tar.gz: cfa5c1befeecc7a4029a28423ae106e5e23ce855d018c1a58b02bb05e475e6e9
3
+ metadata.gz: 5dbe743d3a9f5c41919b66125d379411228f1ff2ebe9a9f6faf1740af02f0482
4
+ data.tar.gz: f48d37196365382f64a6632e4a24e5204dcc6985e26e322b54bb1097344e1fde
5
5
  SHA512:
6
- metadata.gz: 996cac41d300d33993934556b190f44beb9aef5816ae5b478d2cc7a18ea13fe3ab654e871e40d0565a426f77ba0931cda4a09e9248f2be68fc2dc7df89cac987
7
- data.tar.gz: d32a8af42bcd352cf688b1db13e69cfc156fb64029e7ebb608eced97ced5a0fb88bb173dddc70051358b57c29e0e47d21dc5454f3ecbbbfe0a960d14111ef45b
6
+ metadata.gz: 82970733aca54294eb680d9e8be49d4b196f72b450c6f4b0d211c10fcd95ed2fbc6feda63a5cc8588fc4e2335c5c868f3c2e94151c964168ed226edc0b0341f9
7
+ data.tar.gz: 2df28bc3bebbbe7984e348b14ab3c0db75adf93118b0336d7bf58e66706cc336cac8b34de75615800100ba2791540c94783f4109d25a6a5bb2e5decf79f59e33
data/README.md CHANGED
@@ -8,7 +8,7 @@ Now gem can help you with partitioning tables by months. New table for each mont
8
8
  Add this line to your application's Gemfile:
9
9
 
10
10
  ```ruby
11
- gem 'partitioner_pg'
11
+ gem 'pg_partitioner'
12
12
  ```
13
13
 
14
14
  ## Usage
@@ -1,8 +1,8 @@
1
- module PartitionerPg
1
+ module PgPartitioner
2
2
  module SeparationType
3
3
  module Month
4
4
  def create_current_month_table
5
- create_month_tablecreate_month_table(Date.today)
5
+ create_month_table(Date.today)
6
6
  end
7
7
 
8
8
  def create_next_month_table
@@ -35,7 +35,7 @@ module PartitionerPg
35
35
  execute_sql(sql)
36
36
  end
37
37
 
38
- def create_partitioning_by_month_trigger_sql
38
+ def create_partitioning_by_month_triggers
39
39
  sql = "CREATE OR REPLACE FUNCTION #{table_name}_insert_trigger() RETURNS trigger AS
40
40
  $$
41
41
  DECLARE
@@ -118,38 +118,9 @@ module PartitionerPg
118
118
  end
119
119
  end
120
120
 
121
- def create_custom_index(table_name, index_fields, is_unique = false)
122
- ActiveRecord::Migration.add_index table_name, index_fields, unique: is_unique
123
- end
124
-
125
- def create_custom_named_index(table_name, index_fields, name, is_unique = false)
126
- ActiveRecord::Migration.add_index table_name, index_fields, name: name, unique: is_unique
127
- end
128
-
129
121
  def name_of_partition_table(date = Date.today)
130
122
  date.strftime("#{table_name}_y%Ym%m")
131
123
  end
132
-
133
- def execute_sql(sql_string)
134
- ActiveRecord::Base.connection.execute(sql_string)
135
- end
136
-
137
- # Template method
138
- # Column which will determine partition for row (must be date or datetime type). Default value is :created_at
139
- def parting_column
140
- :created_at
141
- end
142
-
143
- # Template method
144
- def partition_table_indexes; end
145
-
146
- def partition_table_named_indexes; end
147
-
148
- # Template method
149
- def partition_table_unique_indexes; end
150
-
151
- # Template method
152
- def partition_table_named_unique_indexes; end
153
124
  end
154
125
  end
155
126
  end
@@ -1,3 +1,3 @@
1
1
  module PartitionerPg
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -0,0 +1,40 @@
1
+ require 'pry'
2
+ require 'pg_partitioner/version'
3
+ require 'pg_partitioner/separation_type/month'
4
+
5
+ module PgPartitioner
6
+ def self.extended(base)
7
+ base.extend(PgPartitioner::SeparationType::Month)
8
+ end
9
+
10
+ # Template method
11
+ # Column which will determine partition for row (must be date or datetime type). Default value is :created_at
12
+ def parting_column
13
+ :created_at
14
+ end
15
+
16
+ # Template method
17
+ def partition_table_indexes; end
18
+
19
+ def partition_table_named_indexes; end
20
+
21
+ # Template method
22
+ def partition_table_unique_indexes; end
23
+
24
+ # Template method
25
+ def partition_table_named_unique_indexes; end
26
+
27
+ private
28
+
29
+ def execute_sql(sql_string)
30
+ ActiveRecord::Base.connection.execute(sql_string)
31
+ end
32
+
33
+ def create_custom_index(table_name, index_fields, is_unique = false)
34
+ ActiveRecord::Migration.add_index table_name, index_fields, unique: is_unique
35
+ end
36
+
37
+ def create_custom_named_index(table_name, index_fields, name, is_unique = false)
38
+ ActiveRecord::Migration.add_index table_name, index_fields, name: name, unique: is_unique
39
+ end
40
+ end
@@ -1,6 +1,6 @@
1
1
  lib = File.expand_path('lib', __dir__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require 'partitioner_pg/version'
3
+ require 'pg_partitioner/version'
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'pg_partitioner'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_partitioner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ovsapyan Mishel
@@ -51,9 +51,9 @@ files:
51
51
  - Rakefile
52
52
  - bin/console
53
53
  - bin/setup
54
- - lib/partitioner_pg.rb
55
- - lib/partitioner_pg/separation_type/month.rb
56
- - lib/partitioner_pg/version.rb
54
+ - lib/pg_partitioner.rb
55
+ - lib/pg_partitioner/separation_type/month.rb
56
+ - lib/pg_partitioner/version.rb
57
57
  - partitioner_pg.gemspec
58
58
  homepage: http://appodeal.com
59
59
  licenses: []
@@ -1,28 +0,0 @@
1
- require "partitioner_pg/version"
2
- require "partitioner_pg/separation_type/month"
3
-
4
- module PartitionerPg
5
- extend ActiveSupport::Concern
6
-
7
- #available types - :month
8
- def initialize(type)
9
- @type = type
10
- end
11
-
12
- module ClassMethods
13
- include SeparationType::Month
14
-
15
- def partitioner_pg(type)
16
- new(type.to_sym)
17
- puts TEST0
18
- end
19
-
20
- private
21
-
22
- def execute_sql(sql)
23
- connection.execute(sql)
24
- end
25
-
26
- end
27
-
28
- end