pg_saurus 5.0.0 → 5.1.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 +4 -4
- data/lib/pg_saurus/errors.rb +6 -0
- data/lib/pg_saurus/migration/set_role_method.rb +46 -0
- data/lib/pg_saurus/version.rb +1 -1
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 4a5ce70db53d9b1636c43b1e2156bc88eeabebf62fbeb39e9ea6141bec719eb3
         | 
| 4 | 
            +
              data.tar.gz: '058c5db2a699fba1f9bec20a0136e4fef2721f03a30b8fc74d1a83197dc20f21'
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 4909fe1c8a4694daf48598534b9d4e0dac565224be24c055187e1fe1a125e542f48fbbd4af646b81d4cf7c2a729b56712f6687abfc5106386e302abdfbf105ed
         | 
| 7 | 
            +
              data.tar.gz: a647b93cd3c8ac24b62c9accf944fa1874d7a902a0129eea64e2f3bf20361f855eff2ed5ee0bb18e66055bf8210a8e8aff1d6da38d663eb4679616a5c436f138
         | 
    
        data/lib/pg_saurus/errors.rb
    CHANGED
    
    | @@ -7,4 +7,10 @@ module PgSaurus | |
| 7 7 |  | 
| 8 8 | 
             
              # Raised if config.ensure_role_set = true, but migration have no role set.
         | 
| 9 9 | 
             
              class RoleNotSetError < Error; end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              # Raised if set_role used for data change migration.
         | 
| 12 | 
            +
              class UseKeepDefaultRoleError < Error; end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              # Raised if keep_default_role used for structure change migration.
         | 
| 15 | 
            +
              class UseSetRoleError < Error; end
         | 
| 10 16 | 
             
            end
         | 
| @@ -13,11 +13,57 @@ module PgSaurus | |
| 13 13 | 
             
                    #
         | 
| 14 14 | 
             
                    # @param role [String]
         | 
| 15 15 | 
             
                    def set_role(role)
         | 
| 16 | 
            +
                      if const_defined?("SeedMigrator") && self.ancestors.include?(SeedMigrator)
         | 
| 17 | 
            +
                        msg = <<~MSG
         | 
| 18 | 
            +
                          Use keep_default_role instead of set_role for data change migration #{self}
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                          Example:
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                            class PopulateExample < ActiveRecord::Migration
         | 
| 23 | 
            +
                              include #{self.ancestors[1]}
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                              keep_default_role
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                              def up
         | 
| 28 | 
            +
                                apply_update "populate_example_data_update"
         | 
| 29 | 
            +
                              end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                              def down
         | 
| 32 | 
            +
                                revert_update "populate_example_data_update"
         | 
| 33 | 
            +
                              end
         | 
| 34 | 
            +
                            end
         | 
| 35 | 
            +
                        MSG
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                        raise PgSaurus::UseKeepDefaultRoleError, msg
         | 
| 38 | 
            +
                      end
         | 
| 39 | 
            +
             | 
| 16 40 | 
             
                      @role = role
         | 
| 17 41 | 
             
                    end
         | 
| 18 42 |  | 
| 19 43 | 
             
                    # Prevents raising exception when ensure_role_set=true and no role is set.
         | 
| 20 44 | 
             
                    def keep_default_role
         | 
| 45 | 
            +
                      if const_defined?("SeedMigrator") && !self.ancestors.include?(SeedMigrator)
         | 
| 46 | 
            +
                        msg = <<~MSG
         | 
| 47 | 
            +
                          Use set_role instead of keep_default_role for structure migration #{self}
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                          Example:
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                            class CreateExamples < ActiveRecord::Migration
         | 
| 52 | 
            +
                              set_role "superhero"
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                              def up
         | 
| 55 | 
            +
                                ...
         | 
| 56 | 
            +
                              end
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                              def down
         | 
| 59 | 
            +
                                ...
         | 
| 60 | 
            +
                              end
         | 
| 61 | 
            +
                            end
         | 
| 62 | 
            +
                        MSG
         | 
| 63 | 
            +
             | 
| 64 | 
            +
                        raise PgSaurus::UseSetRoleError, msg
         | 
| 65 | 
            +
                      end
         | 
| 66 | 
            +
             | 
| 21 67 | 
             
                      @keep_default_role = true
         | 
| 22 68 | 
             
                    end
         | 
| 23 69 |  | 
    
        data/lib/pg_saurus/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: pg_saurus
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 5. | 
| 4 | 
            +
              version: 5.1.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Potapov Sergey
         | 
| @@ -298,7 +298,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 298 298 | 
             
                - !ruby/object:Gem::Version
         | 
| 299 299 | 
             
                  version: '0'
         | 
| 300 300 | 
             
            requirements: []
         | 
| 301 | 
            -
            rubygems_version: 3.0. | 
| 301 | 
            +
            rubygems_version: 3.0.9
         | 
| 302 302 | 
             
            signing_key:
         | 
| 303 303 | 
             
            specification_version: 4
         | 
| 304 304 | 
             
            summary: ActiveRecord extensions for PostgreSQL.
         |