mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-05-12 22:41:38 +00:00
Properly reset the sequences for postgres and database platform conversion
Some checks are pending
Build assets artifact / Build assets artifact (push) Waiting to run
Docker Image Build / build (linux/amd64, amd64, ubuntu-latest) (push) Waiting to run
Docker Image Build / build (linux/arm/v7, armv7, ubuntu-24.04-arm) (push) Waiting to run
Docker Image Build / build (linux/arm64, arm64, ubuntu-24.04-arm) (push) Waiting to run
Docker Image Build / merge (push) Blocked by required conditions
Docker Image Build (FrankenPHP) / build (linux/amd64, amd64, ubuntu-latest) (push) Waiting to run
Docker Image Build (FrankenPHP) / build (linux/arm/v7, armv7, ubuntu-24.04-arm) (push) Waiting to run
Docker Image Build (FrankenPHP) / build (linux/arm64, arm64, ubuntu-24.04-arm) (push) Waiting to run
Docker Image Build (FrankenPHP) / merge (push) Blocked by required conditions
Static analysis / Static analysis (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, sqlite) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, sqlite) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, sqlite) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, sqlite) (push) Waiting to run
Some checks are pending
Build assets artifact / Build assets artifact (push) Waiting to run
Docker Image Build / build (linux/amd64, amd64, ubuntu-latest) (push) Waiting to run
Docker Image Build / build (linux/arm/v7, armv7, ubuntu-24.04-arm) (push) Waiting to run
Docker Image Build / build (linux/arm64, arm64, ubuntu-24.04-arm) (push) Waiting to run
Docker Image Build / merge (push) Blocked by required conditions
Docker Image Build (FrankenPHP) / build (linux/amd64, amd64, ubuntu-latest) (push) Waiting to run
Docker Image Build (FrankenPHP) / build (linux/arm/v7, armv7, ubuntu-24.04-arm) (push) Waiting to run
Docker Image Build (FrankenPHP) / build (linux/arm64, arm64, ubuntu-24.04-arm) (push) Waiting to run
Docker Image Build (FrankenPHP) / merge (push) Blocked by required conditions
Static analysis / Static analysis (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, sqlite) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, sqlite) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, sqlite) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, sqlite) (push) Waiting to run
This fixes issue #1362
This commit is contained in:
parent
83074a2403
commit
19d138632a
2 changed files with 31 additions and 18 deletions
|
|
@ -1713,7 +1713,7 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param;
|
||||||
* length?: scalar|Param|null, // Default: 5
|
* length?: scalar|Param|null, // Default: 5
|
||||||
* width?: scalar|Param|null, // Default: 130
|
* width?: scalar|Param|null, // Default: 130
|
||||||
* height?: scalar|Param|null, // Default: 50
|
* height?: scalar|Param|null, // Default: 50
|
||||||
* font?: scalar|Param|null, // Default: "/home/user/documents/Part-DB-server/vendor/gregwar/captcha-bundle/DependencyInjection/../Generator/Font/captcha.ttf"
|
* font?: scalar|Param|null, // Default: "/home/jan/php/Part-DB-server/vendor/gregwar/captcha-bundle/DependencyInjection/../Generator/Font/captcha.ttf"
|
||||||
* keep_value?: scalar|Param|null, // Default: false
|
* keep_value?: scalar|Param|null, // Default: false
|
||||||
* charset?: scalar|Param|null, // Default: "abcdefhjkmnprstuvwxyz23456789"
|
* charset?: scalar|Param|null, // Default: "abcdefhjkmnprstuvwxyz23456789"
|
||||||
* as_file?: scalar|Param|null, // Default: false
|
* as_file?: scalar|Param|null, // Default: false
|
||||||
|
|
|
||||||
|
|
@ -229,24 +229,37 @@ class DBPlatformConvertCommand extends Command
|
||||||
|
|
||||||
if ($platform instanceof PostgreSQLPlatform) {
|
if ($platform instanceof PostgreSQLPlatform) {
|
||||||
$connection->executeStatement(
|
$connection->executeStatement(
|
||||||
//From: https://wiki.postgresql.org/wiki/Fixing_Sequences
|
//See https://github.com/Part-DB/Part-DB-server/issues/1362
|
||||||
<<<SQL
|
<<<SQL
|
||||||
SELECT 'SELECT SETVAL(' ||
|
DO $$
|
||||||
quote_literal(quote_ident(PGT.schemaname) || '.' || quote_ident(S.relname)) ||
|
DECLARE
|
||||||
', COALESCE(MAX(' ||quote_ident(C.attname)|| '), 1) ) FROM ' ||
|
rec RECORD;
|
||||||
quote_ident(PGT.schemaname)|| '.'||quote_ident(T.relname)|| ';'
|
max_id BIGINT;
|
||||||
FROM pg_class AS S,
|
seq TEXT;
|
||||||
pg_depend AS D,
|
BEGIN
|
||||||
pg_class AS T,
|
FOR rec IN
|
||||||
pg_attribute AS C,
|
SELECT c.table_name
|
||||||
pg_tables AS PGT
|
FROM information_schema.columns c
|
||||||
WHERE S.relkind = 'S'
|
JOIN pg_tables t
|
||||||
AND S.oid = D.objid
|
ON t.tablename = c.table_name AND t.schemaname = 'public'
|
||||||
AND D.refobjid = T.oid
|
WHERE c.column_name = 'id'
|
||||||
AND D.refobjid = C.attrelid
|
AND c.table_schema = 'public'
|
||||||
AND D.refobjsubid = C.attnum
|
LOOP
|
||||||
AND T.relname = PGT.tablename
|
BEGIN
|
||||||
ORDER BY S.relname;
|
seq := pg_get_serial_sequence(rec.table_name, 'id');
|
||||||
|
IF seq IS NOT NULL THEN
|
||||||
|
EXECUTE format('SELECT MAX(id) FROM %I', rec.table_name) INTO max_id;
|
||||||
|
IF max_id IS NOT NULL THEN
|
||||||
|
PERFORM setval(seq, max_id);
|
||||||
|
RAISE NOTICE 'Reset: %.id → %', rec.table_name, max_id;
|
||||||
|
END IF;
|
||||||
|
END IF;
|
||||||
|
EXCEPTION WHEN OTHERS THEN
|
||||||
|
RAISE NOTICE 'Skipped %: %', rec.table_name, SQLERRM;
|
||||||
|
END;
|
||||||
|
END LOOP;
|
||||||
|
END;
|
||||||
|
$$;
|
||||||
SQL);
|
SQL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue