@@ -33,6 +33,86 @@ function patternkit_uninstall(bool $is_syncing): void {
3333 // Cleanup the update results collection value if it exists.
3434 \Drupal::keyValue(LayoutUpdateBatchManager::RESULTS_COLLECTION)
3535 ->deleteAll();
36+
37+ $schema = \Drupal::database()->schema();
38+ if ($schema->tableExists('patternkit_block_validity')) {
39+ $schema->dropTable('patternkit_block_validity');
40+ }
41+ }
42+
43+ /**
44+ * Implements hook_schema().
45+ */
46+ function patternkit_schema(): array {
47+ $schema['patternkit_block_validity'] = [
48+ 'description' => 'Validity stamps for patternkit_block translations (published content index).',
49+ 'fields' => [
50+ 'block_entity_id' => [
51+ 'type' => 'int',
52+ 'unsigned' => TRUE,
53+ 'not null' => TRUE,
54+ 'description' => 'The patternkit_block entity ID.',
55+ ],
56+ 'langcode' => [
57+ 'type' => 'varchar_ascii',
58+ 'length' => 12,
59+ 'not null' => TRUE,
60+ 'description' => 'The translation language code.',
61+ ],
62+ 'block_revision_id' => [
63+ 'type' => 'int',
64+ 'unsigned' => TRUE,
65+ 'not null' => TRUE,
66+ 'description' => 'The block revision ID at validation time.',
67+ ],
68+ 'pattern_revision_id' => [
69+ 'type' => 'int',
70+ 'unsigned' => TRUE,
71+ 'not null' => TRUE,
72+ 'description' => 'The pattern revision ID used when validating.',
73+ ],
74+ 'is_valid' => [
75+ 'type' => 'int',
76+ 'size' => 'tiny',
77+ 'not null' => TRUE,
78+ 'default' => 0,
79+ 'description' => 'Whether content validated successfully.',
80+ ],
81+ 'has_tokens' => [
82+ 'type' => 'int',
83+ 'size' => 'tiny',
84+ 'not null' => TRUE,
85+ 'default' => 0,
86+ 'description' => 'Whether token-shaped values were present at stamp time.',
87+ ],
88+ 'validated_at' => [
89+ 'type' => 'int',
90+ 'not null' => TRUE,
91+ 'description' => 'Unix timestamp when validation ran.',
92+ ],
93+ 'stamp_source' => [
94+ 'type' => 'varchar_ascii',
95+ 'length' => 32,
96+ 'not null' => TRUE,
97+ 'default' => 'save',
98+ 'description' => 'Origin of the stamp (save, cron_scan, etc.).',
99+ ],
100+ 'component_uuid' => [
101+ 'type' => 'varchar_ascii',
102+ 'length' => 128,
103+ 'not null' => FALSE,
104+ 'description' => 'Layout Builder SectionComponent UUID when known.',
105+ ],
106+ ],
107+ 'primary key' => ['block_entity_id', 'langcode'],
108+ 'indexes' => [
109+ 'block_validity_is_valid' => ['is_valid'],
110+ 'block_validity_pattern_revision' => ['pattern_revision_id'],
111+ 'block_validity_component_uuid' => ['component_uuid'],
112+ ],
113+ ];
114+
115+ return $schema;
36116}
37117
38118/**
@@ -681,3 +761,15 @@ function patternkit_update_10310(): string {
681761 );
682762 return t('Restored reusable field storage for the 9.1.x migration window.');
683763}
764+
765+ /**
766+ * Adds the patternkit_block_validity table for block validity stamps.
767+ */
768+ function patternkit_update_10311(): void {
769+ $schema = patternkit_schema();
770+ $table = 'patternkit_block_validity';
771+ $database = \Drupal::database();
772+ if (!$database->schema()->tableExists($table)) {
773+ $database->schema()->createTable($table, $schema[$table]);
774+ }
775+ }
0 commit comments