Elgg
Version 6.1
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
engine
schema
migrations
20171006111953_drop_sites_entity_table.php
Go to the documentation of this file.
1
<?php
2
3
use
Phinx\Migration\AbstractMigration
;
4
5
class
DropSitesEntityTable
extends
AbstractMigration
6
{
10
public
function
up
() {
11
12
if
(!$this->hasTable(
'sites_entity'
) || !$this->hasTable(
'metadata'
)) {
13
return
;
14
}
15
16
$prefix = $this->getAdapter()->getOption(
'table_prefix'
);
17
$rows
= $this->fetchAll(
"
18
SELECT * FROM {$prefix}sites_entity
19
"
);
20
21
$cols = [
'name'
,
'description'
,
'url'
];
22
23
foreach
(
$rows
as $row) {
24
foreach
($cols as $col) {
25
// remove existing metadata... attributes are more important
26
$this->execute(
"
27
DELETE FROM {$prefix}metadata
28
WHERE entity_guid = {$row['guid']} AND
29
name = '{$col}'
30
"
);
31
32
$this->table(
'metadata'
)->insert([[
33
'entity_guid'
=> $row[
'guid'
],
34
'name'
=> $col,
35
'value'
=> $row[$col],
36
'value_type'
=>
'text'
,
37
'owner_guid'
=> 0,
38
'access_id'
=> 2,
39
'time_created'
=> time(),
40
'enabled'
=>
'yes'
,
41
]])->saveData();
42
}
43
}
44
45
// all data migrated, so drop the table
46
$this->table(
'sites_entity'
)->drop()->save();
47
}
48
}
DropSitesEntityTable
Definition:
20171006111953_drop_sites_entity_table.php:5
$rows
$rows
Definition:
redis.php:25
DropSitesEntityTable\up
up()
Move sites_entity attributes to metadata.
Definition:
20171006111953_drop_sites_entity_table.php:10
AbstractMigration
Generated on Wed Dec 4 2024 00:00:22 for Elgg by
1.8.11