mirror of
https://github.com/danog/AsyncOrm.git
synced 2024-11-29 20:29:48 +01:00
Avoid issues when serializing during migration
This commit is contained in:
parent
ee7a261a83
commit
e1c3efd92a
@ -142,6 +142,30 @@ final class MysqlArray extends SqlArray
|
|||||||
ValueType::BOOL => new BoolInt,
|
ValueType::BOOL => new BoolInt,
|
||||||
default => new Passthrough
|
default => new Passthrough
|
||||||
};
|
};
|
||||||
|
/** @psalm-suppress InvalidArgument */
|
||||||
|
parent::__construct(
|
||||||
|
$config,
|
||||||
|
$serializer,
|
||||||
|
$db,
|
||||||
|
"SELECT `value` FROM `{$config->table}` WHERE `key` = :index LIMIT 1",
|
||||||
|
"
|
||||||
|
REPLACE INTO `{$config->table}`
|
||||||
|
SET `key` = :index, `value` = :value
|
||||||
|
",
|
||||||
|
"
|
||||||
|
DELETE FROM `{$config->table}`
|
||||||
|
WHERE `key` = :index
|
||||||
|
",
|
||||||
|
"
|
||||||
|
SELECT count(`key`) as `count` FROM `{$config->table}`
|
||||||
|
",
|
||||||
|
"
|
||||||
|
SELECT `key`, `value` FROM `{$config->table}`
|
||||||
|
",
|
||||||
|
"
|
||||||
|
DELETE FROM `{$config->table}`
|
||||||
|
"
|
||||||
|
);
|
||||||
|
|
||||||
$db->query("
|
$db->query("
|
||||||
CREATE TABLE IF NOT EXISTS `{$config->table}`
|
CREATE TABLE IF NOT EXISTS `{$config->table}`
|
||||||
@ -198,31 +222,6 @@ final class MysqlArray extends SqlArray
|
|||||||
$db->query("OPTIMIZE TABLE `{$config->table}`");
|
$db->query("OPTIMIZE TABLE `{$config->table}`");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @psalm-suppress InvalidArgument */
|
|
||||||
parent::__construct(
|
|
||||||
$config,
|
|
||||||
$serializer,
|
|
||||||
$db,
|
|
||||||
"SELECT `value` FROM `{$config->table}` WHERE `key` = :index LIMIT 1",
|
|
||||||
"
|
|
||||||
REPLACE INTO `{$config->table}`
|
|
||||||
SET `key` = :index, `value` = :value
|
|
||||||
",
|
|
||||||
"
|
|
||||||
DELETE FROM `{$config->table}`
|
|
||||||
WHERE `key` = :index
|
|
||||||
",
|
|
||||||
"
|
|
||||||
SELECT count(`key`) as `count` FROM `{$config->table}`
|
|
||||||
",
|
|
||||||
"
|
|
||||||
SELECT `key`, `value` FROM `{$config->table}`
|
|
||||||
",
|
|
||||||
"
|
|
||||||
DELETE FROM `{$config->table}`
|
|
||||||
"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -108,6 +108,27 @@ class PostgresArray extends SqlArray
|
|||||||
default => new Passthrough
|
default => new Passthrough
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** @psalm-suppress InvalidArgument */
|
||||||
|
parent::__construct(
|
||||||
|
$config,
|
||||||
|
$serializer,
|
||||||
|
$connection,
|
||||||
|
"SELECT value FROM \"bytea_{$config->table}\" WHERE key = :index",
|
||||||
|
"
|
||||||
|
INSERT INTO \"bytea_{$config->table}\"
|
||||||
|
(key,value)
|
||||||
|
VALUES (:index, :value)
|
||||||
|
ON CONFLICT (key) DO UPDATE SET value = :value
|
||||||
|
",
|
||||||
|
"
|
||||||
|
DELETE FROM \"bytea_{$config->table}\"
|
||||||
|
WHERE key = :index
|
||||||
|
",
|
||||||
|
"SELECT count(key) as count FROM \"bytea_{$config->table}\"",
|
||||||
|
"SELECT key, value FROM \"bytea_{$config->table}\"",
|
||||||
|
"DELETE FROM \"bytea_{$config->table}\""
|
||||||
|
);
|
||||||
|
|
||||||
$connection->query("
|
$connection->query("
|
||||||
CREATE TABLE IF NOT EXISTS \"bytea_{$config->table}\"
|
CREATE TABLE IF NOT EXISTS \"bytea_{$config->table}\"
|
||||||
(
|
(
|
||||||
@ -147,27 +168,6 @@ class PostgresArray extends SqlArray
|
|||||||
// @codeCoverageIgnoreEnd
|
// @codeCoverageIgnoreEnd
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @psalm-suppress InvalidArgument */
|
|
||||||
parent::__construct(
|
|
||||||
$config,
|
|
||||||
$serializer,
|
|
||||||
$connection,
|
|
||||||
"SELECT value FROM \"bytea_{$config->table}\" WHERE key = :index",
|
|
||||||
"
|
|
||||||
INSERT INTO \"bytea_{$config->table}\"
|
|
||||||
(key,value)
|
|
||||||
VALUES (:index, :value)
|
|
||||||
ON CONFLICT (key) DO UPDATE SET value = :value
|
|
||||||
",
|
|
||||||
"
|
|
||||||
DELETE FROM \"bytea_{$config->table}\"
|
|
||||||
WHERE key = :index
|
|
||||||
",
|
|
||||||
"SELECT count(key) as count FROM \"bytea_{$config->table}\"",
|
|
||||||
"SELECT key, value FROM \"bytea_{$config->table}\"",
|
|
||||||
"DELETE FROM \"bytea_{$config->table}\""
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function importFromTable(string $fromTable): void
|
protected function importFromTable(string $fromTable): void
|
||||||
|
Loading…
Reference in New Issue
Block a user