This is an example of my source code :
Code: Select all
PgSqlConnection conn = <my PgSqlConnection>;
conn.Open();
PgSqlDump pgSqlDump = new PgSqlDump();
pgSqlDump.Connection = conn;
pgSqlDump.IncludeDrop = false;
pgSqlDump.IncludeBlob = true;
pgSqlDump.GenerateHeader = true;
pgSqlDump.IncludeUsers = false;
pgSqlDump.Mode = Devart.Common.DumpMode.All;
pgSqlDump.Backup(_strFilePath);
But no ForeignKeys created by Entity Framework and INDEXES are backup like (another table that contains forreign key + real index) :CREATE TABLE public."DMGeneral"
(
"GeneralID" bigint,
"SchemaVersion" smallint NOT NULL,
"DataVersion" smallint NOT NULL,
);
...
...
ALTER TABLE ONLY public."DMGeneral" ADD CONSTRAINT "DMGeneral_pkey" PRIMARY KEY ("GeneralID");
So backup the database and restore it lose ALL INDEX !-- Table DMCommon
CREATE INDEX IF NOT EXISTS "IX_DMCommon_FKCodeDetails"
ON public."DMCommon" USING btree
("FKCodeDetails")
TABLESPACE pg_default;
CREATE INDEX IF NOT EXISTS "IX_DMCommon_FKFournitureID"
ON public."DMCommon" USING btree
("FKFournitureID")
TABLESPACE pg_default;
CREATE INDEX IF NOT EXISTS "IX_DMCommon_Nom"
ON public."DMCommon" USING btree
("Nom" COLLATE pg_catalog."default")
TABLESPACE pg_default;
Is it normal ?
I give you the request to get all indexes :
Code: Select all
SELECT n.nspname as "Schema",
c.relname as "Name",
CASE c.relkind
WHEN 'r' THEN 'table'
WHEN 'v' THEN 'view'
WHEN 'i' THEN 'index'
WHEN 'S' THEN 'sequence'
WHEN 's' THEN 'special'
END as "Type",
u.usename as "Owner",
c2.relname as "Table",
idx.indisunique as "Unique",
idx.indisprimary as "Primary",
am.amname as "TypeIndex",
idx.indkey As "IndexKeys",
ARRAY( SELECT pg_get_indexdef(idx.indexrelid, k + 1, true)
FROM generate_subscripts(idx.indkey, 1) as k
ORDER BY k
) as IndexKeyNames
FROM pg_catalog.pg_class c
JOIN pg_catalog.pg_index idx ON idx.indexrelid = c.oid
JOIN pg_catalog.pg_class c2 ON c2.oid = idx.indrelid
JOIN pg_catalog.pg_class c3 ON c3.oid = idx.indexrelid
JOIN pg_catalog.pg_am am ON am.oid = c3.relam
LEFT JOIN pg_catalog.pg_user u ON u.usesysid = c.relowner
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('i','')
AND n.nspname NOT IN ('pg_catalog', 'pg_toast')
ORDER BY 1,2;