Problem/Motivation

The sequences table has been deprecated and will be removed in Drupal 12. Contrib and custom modules will need enough time to change their code or create the sequences table themselves

Proposed resolution

Remove the sequences table in Drupal 12

Remaining tasks

TBD

User interface changes

None

API changes

Sequences table will be removed

Data model changes

Sequences table will be removed

Release notes snippet

TBD

Issue fork drupal-3335756

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

gidarai created an issue. See original summary.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

andypost’s picture

Issue tags: +Drupal 11
andypost’s picture

Title: Drop sequences table in Drupal 12 » Drop sequences table in Drupal 11
catch’s picture

Isn't this supposed to be removed in Drupal 12? At least that's what the deprecation messages in the original issue said.

andypost’s picture

Title: Drop sequences table in Drupal 11 » Drop sequences table in Drupal 12
Issue tags: -Drupal 11 +Drupal 12

sorry, mixed with method deprecation

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

mstrelan’s picture

Status: Active » Closed (duplicate)

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

mstrelan’s picture

Status: Closed (duplicate) » Active

I take that back, there are complications with install_begin_request in install.core.inc that need untangling and it might be better to address that here. Specifically this bit:

if ($install_state['settings_verified']) {
  try {
    $system_schema = system_schema();
    $table = array_key_last($system_schema);
    $install_state['base_system_verified'] = Database::getConnection()->schema()->tableExists($table);
  }
  catch (DatabaseExceptionWrapper) {
    // The last defined table of the base system_schema() does not exist yet.
    // $install_state['base_system_verified'] defaults to FALSE, so the code
    // following below will use the minimal installer service container.
    // As soon as the base system is verified here, the installer operates in
    // a full and regular Drupal environment, without any kind of exceptions.
  }
}
catch’s picture

Theoretically (very theoretically), this might allow us to remove the special casing of system module in the early installer altogether. We should see what happens if that hunk is removed.

mstrelan’s picture

I don't think we can just remove this hunk. There is also install_verify_database_ready which looks at system_schema. If the last table in that function (i.e. sequences) exists then this prevents installing Drupal over and existing installation. With the sequences table gone we lose that check. Perhaps we can check for a different table? It looks like key_value is the first to be created, followed by config. But is it possible that someone is swapping out those services so they are not in the database after all? Not sure if that's possible at install time.

andypost’s picture

btw Drush already doing a check for key_value table to detect install https://github.com/drush-ops/drush/blob/14.x/src/Boot/DrupalBoot8.php#L162

andypost’s picture

I bet even if some module override this (for example mongodb) then Drush will fail somehow OTOH before install core probably should create some tables, so I bet we can remove this check at all

PS: Code search showing no usage in contrib so we can remove it

andypost’s picture

Status: Active » Needs work

Create WIP MR to see if it will work as no usage of the system_schema() found, not sure about check and comment setUpCurrentUser() in core/modules/user/tests/src/Traits/UserCreationTrait.php

Also curious to explore #11

andypost’s picture

andypost’s picture

andypost’s picture

Status: Needs work » Needs review

After removal system module can be installed https://git.drupalcode.org/project/drupal/-/merge_requests/14809/diffs?c...

removed testing commit for #11 as it need more changes breaking resumed installs (when browser closed while install) so the two-phase bootstrap can be removed if drupal_install_system() and services become idempotent to re-run installer. Needs follow-up for that like #2934063: Remove the workaround in \Drupal\Core\Installer\ExtensionListTrait::setPathname() which fails one test now

catch’s picture

mongodb is implemented as a database driver so most of the time it's not actually swapping out database tables but creating collections with the same name so things work transparently - I think, this is based on what @daffie has told me not manual review.

In the early installer, even if you have an alternative database driver that is swapping something out, it's not an installed module yet, so the swapping wouldn't be possible at that point anyway.

tl;dr I think it's OK to rely on key_value here.

andypost’s picture

dcam’s picture

Status: Needs review » Needs work
Issue tags: +Needs update path tests

I assume this needs update path tests, so I'm tagging for them and setting the status to Needs Work.

Otherwise, I didn't find anything to comment on. The sequences table isn't installed anymore. The update function removes it from existing installs. The installer redirects properly if the key_value table is missing. It was a little hard to test the partial install state functionality of core.install.inc, but I think I got it. It worked properly.

catch’s picture

For update path tests, because this is a system update it will be run in every update path test anyway, so I think we could find a generic one and add an assertion there that the table no longer exists after the update? Can't think of anything else though.

andypost’s picture

Status: Needs work » Needs review
Issue tags: -Needs update path tests

Added to core/modules/system/tests/src/Functional/Update/RouteAliasUpdateTest.php as it's only one that already testing database upgrade

dcam’s picture

Status: Needs review » Reviewed & tested by the community

That looks OK to me. Thank you.

catch’s picture

Status: Reviewed & tested by the community » Needs work

We can't add this to the update path test for route aliases, because that update path will be removed entirely in 12.x when we remove all updates added prior to 11.3.0

andypost’s picture

yep, system_update_11201 will gone in 12.x but update is 12000 so probably better to make it 1x001 so the whole could be removed for 12.x

andypost’s picture

Status: Needs work » Needs review

Only TODO can solve it even for new test

catch’s picture

Status: Needs review » Reviewed & tested by the community

New test coverage looks good.

  • catch committed 89ac5060 on main
    task: #3335756 Drop sequences table in Drupal 12
    
    By: gidarai
    By:...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to main, thanks!

-/**
- * Implements hook_schema().
- */
-function system_schema(): array {

This took years, and good to finally get there!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.