#1244 Add a missing migration
Merged 4 years ago by mprahl. Opened 4 years ago by mprahl.

@@ -0,0 +1,24 @@ 

+ """Add a missing uniqueness constraint to module_builds_to_module_buildrequires

+ 

+ Revision ID: 65ad4fcdbce6

+ Revises: 6d503efcd2b8

+ Create Date: 2019-04-30 19:56:38.447195

+ 

+ """

+ 

+ # revision identifiers, used by Alembic.

+ revision = '65ad4fcdbce6'

+ down_revision = '6d503efcd2b8'

+ 

+ from alembic import op

+ import sqlalchemy as sa

+ 

+ 

+ def upgrade():

+     with op.batch_alter_table('module_builds_to_module_buildrequires') as b:

+         b.create_unique_constraint('unique_buildrequires', ['module_id', 'module_buildrequire_id'])

+ 

+ 

+ def downgrade():

+     with op.batch_alter_table('module_builds_to_module_buildrequires') as b:

+         b.drop_constraint('unique_buildrequires', type_='unique')

@@ -191,7 +191,7 @@ 

      ref_build_context = db.Column(db.String)

      build_context = db.Column(db.String)

      runtime_context = db.Column(db.String)

-     context = db.Column(db.String, server_default=DEFAULT_MODULE_CONTEXT)

+     context = db.Column(db.String, nullable=False, server_default=DEFAULT_MODULE_CONTEXT)

      state = db.Column(db.Integer, nullable=False)

      state_reason = db.Column(db.String)

      modulemd = db.Column(db.String, nullable=False)

@@ -16,6 +16,7 @@ 

      # timestamp.  Module version defines upgrade path for the particular

      # update stream.

      version: 2

+     context: '00000000'

      # A short summary describing the module, required

      summary: An example nginx module

      # A verbose description of the module, required

@@ -204,20 +204,20 @@ 

          """ Test preparation of directory with output files """

          dir_path = self.cg._prepare_file_directory()

          with io.open(path.join(dir_path, "modulemd.txt"), encoding="utf-8") as mmd:

-             assert len(mmd.read()) == 1136

+             assert len(mmd.read()) == 1160

  

      def test_prepare_file_directory_per_arch_mmds(self):

          """ Test preparation of directory with output files """

          self.cg.arches = ["x86_64", "i686"]

          dir_path = self.cg._prepare_file_directory()

          with io.open(path.join(dir_path, "modulemd.txt"), encoding="utf-8") as mmd:

-             assert len(mmd.read()) == 1136

+             assert len(mmd.read()) == 1160

  

          with io.open(path.join(dir_path, "modulemd.x86_64.txt"), encoding="utf-8") as mmd:

-             assert len(mmd.read()) == 236

+             assert len(mmd.read()) == 256

  

          with io.open(path.join(dir_path, "modulemd.i686.txt"), encoding="utf-8") as mmd:

-             assert len(mmd.read()) == 234

+             assert len(mmd.read()) == 254

  

      @patch.dict("sys.modules", krbV=Mock())

      @patch("module_build_service.builder.KojiModuleBuilder.KojiClientSession")
@@ -290,12 +290,12 @@ 

          assert ret == {

              "arch": "x86_64",

              "buildroot_id": 1,

-             "checksum": "96b7739ffa3918e6ac3e3bd422b064ea",

+             "checksum": "aed2e2774c82cbc19fe9555f70cafd79",

              "checksum_type": "md5",

              "components": [],

              "extra": {"typeinfo": {"module": {}}},

              "filename": "modulemd.x86_64.txt",

-             "filesize": 1138,

+             "filesize": 1162,

              "type": "file",

          }

  
@@ -333,7 +333,7 @@ 

          assert ret == {

              "arch": "x86_64",

              "buildroot_id": 1,

-             "checksum": "bb6ba47519b68aee215d095fd2c57c70",

+             "checksum": "5fbad2ef9b6c5496bdce4368ca3182d6",

              "checksum_type": "md5",

              "components": [

                  {
@@ -348,7 +348,7 @@ 

              ],

              "extra": {"typeinfo": {"module": {}}},

              "filename": "modulemd.x86_64.txt",

-             "filesize": 296,

+             "filesize": 316,

              "type": "file",

          }

  

@@ -625,8 +625,8 @@ 

                  }

              ],

              "arch": "noarch",

-             "filesize": 1138,

-             "checksum": "96b7739ffa3918e6ac3e3bd422b064ea",

+             "filesize": 1162,

+             "checksum": "aed2e2774c82cbc19fe9555f70cafd79",

              "checksum_type": "md5",

              "type": "file",

              "extra": {
@@ -652,7 +652,7 @@ 

                      "version": "2",

                      "module_build_service_id": 2,

                      "content_koji_tag": "module-nginx-1.2",

-                     "modulemd_str": "# Document type identifier\ndocument: modulemd\n# Module metadata format version\nversion: 1\ndata:\n    # Module name, optional\n    # Typically filled in by the buildsystem, using the VCS repository\n    # name as the name of the module.\n    name: nginx\n    # Module update stream, optional\n    # Typically filled in by the buildsystem, using the VCS branch name\n    # as the name of the stream.\n    stream: 1\n    # Module version, integer, optional, cannot be negative\n    # Typically filled in by the buildsystem, using the VCS commit\n    # timestamp.  Module version defines upgrade path for the particular\n    # update stream.\n    version: 2\n    # A short summary describing the module, required\n    summary: An example nginx module\n    # A verbose description of the module, required\n    description: >\n        A module for the tests of module build service ’\n    # Module and content licenses in the Fedora license identifier\n    # format, required\n    license:\n        # Module license, required\n        # This list covers licenses used for the module metadata, SPEC\n        # files or extra patches\n        module:\n            - MIT\n"

+                     "modulemd_str": "# Document type identifier\ndocument: modulemd\n# Module metadata format version\nversion: 1\ndata:\n    # Module name, optional\n    # Typically filled in by the buildsystem, using the VCS repository\n    # name as the name of the module.\n    name: nginx\n    # Module update stream, optional\n    # Typically filled in by the buildsystem, using the VCS branch name\n    # as the name of the stream.\n    stream: 1\n    # Module version, integer, optional, cannot be negative\n    # Typically filled in by the buildsystem, using the VCS commit\n    # timestamp.  Module version defines upgrade path for the particular\n    # update stream.\n    version: 2\n    context: '00000000'\n    # A short summary describing the module, required\n    summary: An example nginx module\n    # A verbose description of the module, required\n    description: >\n        A module for the tests of module build service ’\n    # Module and content licenses in the Fedora license identifier\n    # format, required\n    license:\n        # Module license, required\n        # This list covers licenses used for the module metadata, SPEC\n        # files or extra patches\n        module:\n            - MIT\n"

                  }

              }

          },

@@ -625,8 +625,8 @@ 

                  }

              ],

              "arch": "noarch",

-             "filesize": 1138,

-             "checksum": "96b7739ffa3918e6ac3e3bd422b064ea",

+             "filesize": 1162,

+             "checksum": "aed2e2774c82cbc19fe9555f70cafd79",

              "checksum_type": "md5",

              "type": "file",

              "extra": {
@@ -661,7 +661,7 @@ 

                      "version": "2",

                      "module_build_service_id": 2,

                      "content_koji_tag": "module-nginx-1.2",

-                     "modulemd_str": "# Document type identifier\ndocument: modulemd\n# Module metadata format version\nversion: 1\ndata:\n    # Module name, optional\n    # Typically filled in by the buildsystem, using the VCS repository\n    # name as the name of the module.\n    name: nginx\n    # Module update stream, optional\n    # Typically filled in by the buildsystem, using the VCS branch name\n    # as the name of the stream.\n    stream: 1\n    # Module version, integer, optional, cannot be negative\n    # Typically filled in by the buildsystem, using the VCS commit\n    # timestamp.  Module version defines upgrade path for the particular\n    # update stream.\n    version: 2\n    # A short summary describing the module, required\n    summary: An example nginx module\n    # A verbose description of the module, required\n    description: >\n        A module for the tests of module build service ’\n    # Module and content licenses in the Fedora license identifier\n    # format, required\n    license:\n        # Module license, required\n        # This list covers licenses used for the module metadata, SPEC\n        # files or extra patches\n        module:\n            - MIT\n"

+                     "modulemd_str": "# Document type identifier\ndocument: modulemd\n# Module metadata format version\nversion: 1\ndata:\n    # Module name, optional\n    # Typically filled in by the buildsystem, using the VCS repository\n    # name as the name of the module.\n    name: nginx\n    # Module update stream, optional\n    # Typically filled in by the buildsystem, using the VCS branch name\n    # as the name of the stream.\n    stream: 1\n    # Module version, integer, optional, cannot be negative\n    # Typically filled in by the buildsystem, using the VCS commit\n    # timestamp.  Module version defines upgrade path for the particular\n    # update stream.\n    version: 2\n    context: '00000000'\n    # A short summary describing the module, required\n    summary: An example nginx module\n    # A verbose description of the module, required\n    description: >\n        A module for the tests of module build service ’\n    # Module and content licenses in the Fedora license identifier\n    # format, required\n    license:\n        # Module license, required\n        # This list covers licenses used for the module metadata, SPEC\n        # files or extra patches\n        module:\n            - MIT\n"

                  }

              }

          },

This adds a migration that adds a missing uniqueness constraint that was defined in the model. The uniqueness constraint was added in 599c881, but it was not part of the migration.

Additionally, this sets nullable=False on the ModuleBuild.context column model to match the migration. The context column was added in d83e689. The migration set nullable=False, but the model kept the default of nullable=True. This caused mbs-manager db migrate to create a migration for setting the context collumn to nullable=True. This is not desired, so its best to just set this in the model.

rebased onto d93bc3c3539d82b9b8c7468616126c3eb9e15db0

4 years ago

@jkaluza could you please take a look at this?

rebased onto eeff0f49f39b8368360d46aea0fd8b9fbb6cf685

4 years ago

These changes are caused by the added context to nginx_mmd.yaml, right?

It looks good to me, +1.

rebased onto ea838a9

4 years ago

These changes are caused by the added context to nginx_mmd.yaml, right?

Correct

Okay, this is now rebased. It should be good to merge if C3I passes.

Build 84dc82c FAILED!
Rebase or make new commits to rebuild.

^^ That was a failure to check out the code from the Pagure repo. Rerunning the job, hopefully with better results this time.

C3I passed, so I'll go ahead and merge this.

Pull-Request has been merged by mprahl

4 years ago