Skip to content
Extraits de code Groupes Projets
Valider ffb02492 rédigé par nicod's avatar nicod
Parcourir les fichiers

Supprimer la table spip_blocks_liens et déplacer objet/id_objet dans spip_blocks

parent df6257c5
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -47,6 +47,9 @@ function blocks_declarer_tables_objets_sql($tables) { ...@@ -47,6 +47,9 @@ function blocks_declarer_tables_objets_sql($tables) {
'field' => [ 'field' => [
'id_block' => 'bigint(21) NOT NULL', 'id_block' => 'bigint(21) NOT NULL',
'id_blocktype' => 'bigint(21) NOT NULL DEFAULT 0', 'id_blocktype' => 'bigint(21) NOT NULL DEFAULT 0',
'objet' => 'varchar(25) DEFAULT "" NOT NULL',
'id_objet' => 'bigint(21) DEFAULT "0" NOT NULL',
'rang_lien' => 'int(4) DEFAULT "0" NOT NULL',
'ancre' => 'varchar(20) NOT NULL DEFAULT ""', 'ancre' => 'varchar(20) NOT NULL DEFAULT ""',
'valeurs' => 'text NOT NULL DEFAULT ""', 'valeurs' => 'text NOT NULL DEFAULT ""',
'date' => 'datetime NOT NULL DEFAULT "0000-00-00 00:00:00"', 'date' => 'datetime NOT NULL DEFAULT "0000-00-00 00:00:00"',
...@@ -56,13 +59,15 @@ function blocks_declarer_tables_objets_sql($tables) { ...@@ -56,13 +59,15 @@ function blocks_declarer_tables_objets_sql($tables) {
'key' => [ 'key' => [
'PRIMARY KEY' => 'id_block', 'PRIMARY KEY' => 'id_block',
'KEY id_blocktype' => 'id_blocktype', 'KEY id_blocktype' => 'id_blocktype',
'KEY objet' => 'objet',
'KEY id_objet' => 'id_objet',
'KEY statut' => 'statut', 'KEY statut' => 'statut',
], ],
'titre' => 'id_blocktype AS titre', 'titre' => 'id_blocktype AS titre',
'date' => 'date', 'date' => 'date',
'champs_editables' => ['id_blocktype', 'ancre'], 'champs_editables' => ['id_blocktype', 'id_objet', 'objet', 'ancre'],
'champs_versionnes' => ['id_blocktype', 'ancre', 'valeurs'], 'champs_versionnes' => ['id_blocktype', 'id_objet', 'objet', 'ancre', 'valeurs'],
'tables_jointures' => ['spip_blocks_liens'], 'tables_jointures' => ['spip_blocktypes'],
'statut_textes_instituer' => [ 'statut_textes_instituer' => [
'prepa' => 'texte_statut_en_cours_redaction', 'prepa' => 'texte_statut_en_cours_redaction',
'prop' => 'texte_statut_propose_evaluation', 'prop' => 'texte_statut_propose_evaluation',
...@@ -118,7 +123,7 @@ function blocks_declarer_tables_objets_sql($tables) { ...@@ -118,7 +123,7 @@ function blocks_declarer_tables_objets_sql($tables) {
]; ];
// jointure potentielle avec tous les objets // jointure potentielle avec tous les objets
$tables[]['tables_jointures'][] = 'blocks_liens'; $tables[]['tables_jointures'][] = 'blocks';
return $tables; return $tables;
} }
...@@ -134,21 +139,6 @@ function blocks_declarer_tables_objets_sql($tables) { ...@@ -134,21 +139,6 @@ function blocks_declarer_tables_objets_sql($tables) {
*/ */
function blocks_declarer_tables_auxiliaires($tables) { function blocks_declarer_tables_auxiliaires($tables) {
$tables['spip_blocks_liens'] = [
'field' => [
'id_block' => 'bigint(21) DEFAULT "0" NOT NULL',
'id_objet' => 'bigint(21) DEFAULT "0" NOT NULL',
'objet' => 'varchar(25) DEFAULT "" NOT NULL',
'rang_lien' => 'int(4) DEFAULT "0" NOT NULL',
'vu' => 'varchar(6) DEFAULT "non" NOT NULL',
],
'key' => [
'PRIMARY KEY' => 'id_block,id_objet,objet',
// clé unique : un block ne peut être associé qu'à un seul objet
'UNIQUE KEY id_block' => 'id_block',
],
];
// table de liaison entre blocktypes enfants / parents // table de liaison entre blocktypes enfants / parents
$tables['spip_blocktypes_liens'] = [ $tables['spip_blocktypes_liens'] = [
'field' => [ 'field' => [
......
...@@ -26,7 +26,7 @@ function blocks_upgrade($nom_meta_base_version, $version_cible) { ...@@ -26,7 +26,7 @@ function blocks_upgrade($nom_meta_base_version, $version_cible) {
$maj = []; $maj = [];
$maj['create'] = [ $maj['create'] = [
['maj_tables', ['spip_blocks', 'spip_blocks_liens', 'spip_blocktypes', 'spip_blocktypes_liens']], ['maj_tables', ['spip_blocks', 'spip_blocktypes', 'spip_blocktypes_liens']],
['blocks_installe_config'], ['blocks_installe_config'],
]; ];
...@@ -39,6 +39,12 @@ function blocks_upgrade($nom_meta_base_version, $version_cible) { ...@@ -39,6 +39,12 @@ function blocks_upgrade($nom_meta_base_version, $version_cible) {
['maj_tables', ['spip_blocks', 'spip_blocktypes', 'spip_blocktypes_liens']], ['maj_tables', ['spip_blocks', 'spip_blocktypes', 'spip_blocktypes_liens']],
]; ];
$maj['1.3.0'] = [
['maj_tables', ['spip_blocks', 'spip_blocktypes', 'spip_blocktypes_liens']],
['blocks_update_1_3_0'],
['sql_drop_table', 'spip_blocks_liens'],
];
include_spip('base/upgrade'); include_spip('base/upgrade');
maj_plugin($nom_meta_base_version, $version_cible, $maj); maj_plugin($nom_meta_base_version, $version_cible, $maj);
} }
...@@ -146,3 +152,19 @@ function blocks_update_1_0_1() { ...@@ -146,3 +152,19 @@ function blocks_update_1_0_1() {
sql_alter('TABLE spip_blocks_liens CHANGE id_bloc id_block bigint(21) NOT NULL DEFAULT 0'); sql_alter('TABLE spip_blocks_liens CHANGE id_bloc id_block bigint(21) NOT NULL DEFAULT 0');
sql_alter('TABLE spip_blocktypes CHANGE id_blocs_type id_blocktype bigint(21) NOT NULL AUTO_INCREMENT'); sql_alter('TABLE spip_blocktypes CHANGE id_blocs_type id_blocktype bigint(21) NOT NULL AUTO_INCREMENT');
} }
function blocks_update_1_3_0() {
// transférer les liens de spip_blocks_liens vers spip_blocks
$blocks_liens = sql_allfetsel('*', 'spip_blocks_liens');
foreach ($blocks_liens as $blocks_lien) {
sql_updateq(
'spip_blocks',
[
'id_objet' => $blocks_lien['id_objet'],
'objet' => $blocks_lien['objet'],
'rang_lien' => $blocks_lien['rang_lien'],
],
'id_block = ' . $blocks_lien['id_block']
);
}
}
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
compatibilite="[4.2.0;4.2.*]" compatibilite="[4.2.0;4.2.*]"
logo="prive/themes/spip/images/blocks-xx.svg" logo="prive/themes/spip/images/blocks-xx.svg"
documentation="" documentation=""
schema="1.2.0" schema="1.3.0"
> >
<nom>Blocks</nom> <nom>Blocks</nom>
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter