Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
0c8931dd
Commit
0c8931dd
authored
14 years ago
by
Angie Byron
Browse files
Options
Downloads
Patches
Plain Diff
#986992
follow-up by yched, saintiss: Fix to field_sql_storage_update_7001().
parent
75a7c31c
No related branches found
No related tags found
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/field/modules/field_sql_storage/field_sql_storage.install
+33
-31
33 additions, 31 deletions
...field/modules/field_sql_storage/field_sql_storage.install
with
33 additions
and
31 deletions
modules/field/modules/field_sql_storage/field_sql_storage.install
+
33
−
31
View file @
0c8931dd
...
...
@@ -136,40 +136,42 @@ function field_sql_storage_update_7001(&$sandbox) {
$table
=
key
(
$sandbox
[
'tables'
]);
$type
=
array_shift
(
$sandbox
[
'tables'
]);
// Add the 'entity_type' column.
if
(
!
db_field_exists
(
$table
,
'entity_type'
))
{
$column
=
array
(
'type'
=>
'varchar'
,
'length'
=>
128
,
'not null'
=>
TRUE
,
'default'
=>
''
,
'description'
=>
'The entity type this data is attached to.'
,
);
db_add_field
(
$table
,
'entity_type'
,
$column
);
// Populate the 'entity_type' column based on the 'etid' column.
foreach
(
$sandbox
[
'etids'
]
as
$etid
=>
$entity_type
)
{
db_update
(
$table
)
->
fields
(
array
(
'entity_type'
=>
$entity_type
))
->
condition
(
'etid'
,
$etid
)
->
execute
();
if
(
db_table_exists
(
$table
))
{
// Add the 'entity_type' column.
if
(
!
db_field_exists
(
$table
,
'entity_type'
))
{
$column
=
array
(
'type'
=>
'varchar'
,
'length'
=>
128
,
'not null'
=>
TRUE
,
'default'
=>
''
,
'description'
=>
'The entity type this data is attached to.'
,
);
db_add_field
(
$table
,
'entity_type'
,
$column
);
// Populate the 'entity_type' column based on the 'etid' column.
foreach
(
$sandbox
[
'etids'
]
as
$etid
=>
$entity_type
)
{
db_update
(
$table
)
->
fields
(
array
(
'entity_type'
=>
$entity_type
))
->
condition
(
'etid'
,
$etid
)
->
execute
();
}
// Index the new column.
db_add_index
(
$table
,
'entity_type'
,
array
(
'entity_type'
));
}
// Index the new column.
db_add_index
(
$table
,
'entity_type'
,
array
(
'entity_type'
));
}
// Use the 'entity_type' column in the primary key.
db_drop_primary_key
(
$table
);
$primary_keys
=
array
(
'data'
=>
array
(
'entity_type'
,
'entity_id'
,
'deleted'
,
'delta'
,
'language'
),
'revision'
=>
array
(
'entity_type'
,
'entity_id'
,
'revision_id'
,
'deleted'
,
'delta'
,
'language'
),
);
db_add_primary_key
(
$table
,
$primary_keys
[
$type
]);
// Use the 'entity_type' column in the primary key.
db_drop_primary_key
(
$table
);
$primary_keys
=
array
(
'data'
=>
array
(
'entity_type'
,
'entity_id'
,
'deleted'
,
'delta'
,
'language'
),
'revision'
=>
array
(
'entity_type'
,
'entity_id'
,
'revision_id'
,
'deleted'
,
'delta'
,
'language'
),
);
db_add_primary_key
(
$table
,
$primary_keys
[
$type
]);
// Drop the 'etid' column.
if
(
db_field_exists
(
$table
,
'etid'
))
{
db_drop_field
(
$table
,
'etid'
);
// Drop the 'etid' column.
if
(
db_field_exists
(
$table
,
'etid'
))
{
db_drop_field
(
$table
,
'etid'
);
}
}
// Report progress.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment