pg_partitioner 0.1.0 → 0.3.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: 1d5a117c351787656181fa6f4adee3ba98236ec3106aff8f4072977bd72bfdea
4
+ data.tar.gz: ae3e677132e80679d7a66a05798ebeca89b2f66c77e004886be71010e627bc0f
5
5
  SHA512:
6
- metadata.gz: 996cac41d300d33993934556b190f44beb9aef5816ae5b478d2cc7a18ea13fe3ab654e871e40d0565a426f77ba0931cda4a09e9248f2be68fc2dc7df89cac987
7
- data.tar.gz: d32a8af42bcd352cf688b1db13e69cfc156fb64029e7ebb608eced97ced5a0fb88bb173dddc70051358b57c29e0e47d21dc5454f3ecbbbfe0a960d14111ef45b
6
+ metadata.gz: 1cc94920f91c331cdb8b329082cda40be0e713ada04f5f7cfc3dfd1bcc4983f9dcaea1d11e31b2af6e19873306ea8f5ab45df2496268be54d8a21613f29d23fe
7
+ data.tar.gz: 5578a26c20de88754a8b058dabbebc144daff2747b028fb31f483bbde42605b80a905a882d51c650ea64937cc31ab5a3fbd0d93ff9fa3075154de32cc91ee06e
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.3.0'
3
3
  end
@@ -0,0 +1,39 @@
1
+ require 'pg_partitioner/version'
2
+ require 'pg_partitioner/separation_type/month'
3
+
4
+ module PgPartitioner
5
+ def self.extended(base)
6
+ base.extend(PgPartitioner::SeparationType::Month)
7
+ end
8
+
9
+ # Template method
10
+ # Column which will determine partition for row (must be date or datetime type). Default value is :created_at
11
+ def parting_column
12
+ :created_at
13
+ end
14
+
15
+ # Template method
16
+ def partition_table_indexes; end
17
+
18
+ def partition_table_named_indexes; end
19
+
20
+ # Template method
21
+ def partition_table_unique_indexes; end
22
+
23
+ # Template method
24
+ def partition_table_named_unique_indexes; end
25
+
26
+ private
27
+
28
+ def execute_sql(sql_string)
29
+ ActiveRecord::Base.connection.execute(sql_string)
30
+ end
31
+
32
+ def create_custom_index(table_name, index_fields, is_unique = false)
33
+ ActiveRecord::Migration.add_index table_name, index_fields, unique: is_unique
34
+ end
35
+
36
+ def create_custom_named_index(table_name, index_fields, name, is_unique = false)
37
+ ActiveRecord::Migration.add_index table_name, index_fields, name: name, unique: is_unique
38
+ end
39
+ 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,14 +1,14 @@
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.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ovsapyan Mishel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-04 00:00:00.000000000 Z
11
+ date: 2022-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -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