Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/en/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ English | [Português (Brasil)](../pt-BR/release-notes.md)

Fifth public pre-release of PGMS. It is an alpha for evaluation with synthetic/disposable data. Build label: M1053. The binaries are built and attested by the same [release workflow](../../.github/workflows/release.yml) as the previous releases. **License change:** from this release on, original work is under Apache-2.0, with credits in `NOTICE`; releases through alpha.4 remain under MIT.

## In development (not yet released)

These changes are on `main` and will be part of the next pre-release; the downloads below are still v0.1.0-alpha.5.

- **Indexes in database diagrams.** Each table of a diagram has an **Indexes** section, closed by default, with one row per index when opened: method (GIN, GiST, SP-GiST, BRIN, Hash), key columns or expressions, operator class when not the default (such as `gin_trgm_ops`), `INCLUDE`, UNIQUE, EXCLUDE, partial and invalid, with the predicate and the full `CREATE INDEX` in the tooltip. A warning marks a table with a foreign key that no index serves and opens **Find Unindexed Foreign Keys…**, which also arrives in this change: on a database in Object Explorer it lists such keys from the catalog and creates the indexes from a reviewed script, concurrently or in one transaction. **Show Indexes** and **Refresh** are in the diagram menu. Each save writes the indexes of each table into the diagram definition (format 2) for tools and AI agents that read it; older diagrams open unchanged. Read only: indexes are still created in **Indexes/Keys…**. SSMS 22.11 shows no indexes in a diagram. Suggested by a PGMS user.

## What changed since v0.1.0-alpha.4

- **Database diagrams.** SSMS-style diagrams saved on the server: add tables and related tables, drag a column to create a foreign key, Arrange Tables, zoom, table views, annotations, new tables and column editing inside the diagram. Database changes are shown as a SQL script first.
Expand Down
2 changes: 2 additions & 0 deletions docs/en/user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Identity and sequence operations distinguish configured START from RESTART. A re

In Object Explorer, right-click **Database Diagrams** under a database and choose **New Database Diagram**. The first time, PGMS asks to create its support objects (schema `pgms`). Add tables with **Add Table** or **Add Related Tables**, drag a column onto another to create a foreign key, and use **Arrange Tables** to lay them out. Saving shows the SQL script of any change to the database for review.

**Indexes.** Each table shows an **Indexes** section below its columns, closed by default so diagrams laid out before keep their spacing: the header gives the count and the methods other than b-tree (for example `Indexes (3) · GIN`), and its tooltip lists every index. Click the header to show one row per index: name, method when it is not b-tree (Hash, GIN, GiST, SP-GiST, BRIN), key columns or expressions, the operator class when it is not the default (such as `gin_trgm_ops`, `jsonb_path_ops` or `text_pattern_ops`), `INCLUDE` columns, and UNIQUE, EXCLUDE, partial or invalid. The row tooltip has the predicate of a partial index and the full `CREATE INDEX`. A gold key marks the primary key, a silver key a unique or exclusion constraint, and a tree a plain index. A warning triangle in the title marks a table with a foreign key that no index serves, by the same rule as **Find Unindexed Foreign Keys…**; click it, or use the item of the table menu, to open that window. **Show Indexes** in the diagram menu turns the sections and the warning off and on for that diagram, and **Refresh** reads the tables and their indexes again. The section is read only: create or change indexes in **Indexes/Keys…** (double-click an index row) and the other dialogs. Every save writes the indexes of each table, read from the catalog inside the save transaction, into the diagram definition (`pgms.diagrams.definition`, format 2), so tools and AI agents that read the diagram see them; changes made only in the database do not mark the diagram as changed and reach the definition on its next save. Diagrams saved by earlier versions open as they were and are written in the new format by their next save. SSMS 22.11 shows no indexes in a diagram; this section is a PGMS addition.

## Query Designer

**Query ▸ Design Query in Editor** (`Ctrl+Shift+Q`) opens the statement under the cursor, or the selection, in the Diagram, Criteria and SQL panes. **OK** replaces that statement in the editor; nothing is executed. On an empty line it starts empty and inserts at the cursor. `UNION` and `WITH` open only in the SQL pane.
Expand Down
6 changes: 6 additions & 0 deletions docs/pt-BR/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

Quinta pré-release pública do PGMS. É uma alpha para avaliação com dados sintéticos ou descartáveis. Rótulo de build: M1053. Os binários são gerados e atestados pelo mesmo [workflow de release](../../.github/workflows/release.yml) das versões anteriores. **Mudança de licença:** a partir desta versão, o trabalho próprio está sob Apache-2.0, com créditos no `NOTICE`; as versões até a alpha.4 continuam sob MIT.

## Em desenvolvimento (ainda não publicado)

Estas mudanças estão no `main` e farão parte da próxima pré-release; os downloads abaixo continuam sendo da v0.1.0-alpha.5.

- **Índices nos diagramas de banco.** Cada tabela de um diagrama tem uma seção **Indexes**, recolhida por padrão, com uma linha por índice quando aberta: método (GIN, GiST, SP-GiST, BRIN, Hash), colunas ou expressões da chave, classe de operadores quando não é a padrão (como `gin_trgm_ops`), `INCLUDE`, UNIQUE, EXCLUDE, parcial e inválido, com o predicado e o `CREATE INDEX` completo na dica. Um aviso marca a tabela com chave estrangeira que nenhum índice atende e abre **Find Unindexed Foreign Keys…**, que também chega nesta mudança: num banco do Object Explorer, lista essas chaves pelo catálogo e cria os índices a partir de um script revisado, de forma concorrente ou em uma transação. **Show Indexes** e **Refresh** ficam no menu do diagrama. Cada gravação escreve os índices de cada tabela na definição do diagrama (formato 2) para ferramentas e agentes de IA que a leem; diagramas antigos abrem sem mudança. Só leitura: índices continuam sendo criados em **Indexes/Keys…**. O SSMS 22.11 não mostra índices no diagrama. Sugestão de um usuário do PGMS.

## O que mudou desde a v0.1.0-alpha.4

- **Diagramas de banco.** Diagramas como os do SSMS, salvos no servidor: adicionar tabelas e tabelas relacionadas, arrastar uma coluna para criar chave estrangeira, Arrange Tables, zoom, modos de exibição, anotações, tabelas novas e edição de colunas dentro do diagrama. Alterações no banco aparecem antes como script SQL.
Expand Down
2 changes: 2 additions & 0 deletions docs/pt-BR/user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Identity e sequences distinguem START configurado de RESTART. Reiniciar pode rep

No Object Explorer, clique com o botão direito em **Database Diagrams**, dentro de um banco, e escolha **New Database Diagram**. Na primeira vez, o PGMS pede para criar seus objetos de suporte (schema `pgms`). Adicione tabelas com **Add Table** ou **Add Related Tables**, arraste uma coluna sobre outra para criar uma chave estrangeira e use **Arrange Tables** para organizar. Ao salvar, o PGMS mostra o script SQL de qualquer alteração no banco para revisão.

**Índices.** Cada tabela mostra uma seção **Indexes** abaixo das colunas, recolhida por padrão para que diagramas já organizados mantenham o espaçamento: o cabeçalho traz a quantidade e os métodos que não são b-tree (por exemplo `Indexes (3) · GIN`), e a dica dele lista todos os índices. Clique no cabeçalho para ver uma linha por índice: nome, método quando não é b-tree (Hash, GIN, GiST, SP-GiST, BRIN), colunas ou expressões da chave, a classe de operadores quando não é a padrão (como `gin_trgm_ops`, `jsonb_path_ops` ou `text_pattern_ops`), colunas `INCLUDE` e UNIQUE, EXCLUDE, parcial (partial) ou inválido (invalid). A dica da linha traz o predicado de um índice parcial e o `CREATE INDEX` completo. Uma chave dourada marca a chave primária, uma chave prateada uma constraint UNIQUE ou de exclusão, e uma árvore um índice comum. Um triângulo de aviso no título marca a tabela com chave estrangeira que nenhum índice atende, pela mesma regra de **Find Unindexed Foreign Keys…**; clique nele, ou use o item do menu da tabela, para abrir essa janela. **Show Indexes**, no menu do diagrama, liga e desliga as seções e o aviso naquele diagrama, e **Refresh** lê de novo as tabelas e seus índices. A seção é só leitura: crie ou altere índices em **Indexes/Keys…** (duplo clique numa linha de índice) e nos outros diálogos. Toda gravação escreve os índices de cada tabela, lidos do catálogo dentro da transação da gravação, na definição do diagrama (`pgms.diagrams.definition`, formato 2), para que ferramentas e agentes de IA que leem o diagrama os vejam; mudanças feitas só no banco não marcam o diagrama como alterado e chegam à definição na próxima gravação. Diagramas salvos por versões anteriores abrem como estavam e passam ao formato novo na próxima gravação. O SSMS 22.11 não mostra índices no diagrama; esta seção é um acréscimo do PGMS.

## Query Designer

**Query ▸ Design Query in Editor** (`Ctrl+Shift+Q`) abre a instrução sob o cursor, ou a seleção, nos painéis Diagram, Criteria e SQL. **OK** substitui essa instrução no editor; nada é executado. Numa linha vazia, abre vazio e insere no cursor. `UNION` e `WITH` abrem apenas no painel SQL.
Expand Down
5 changes: 3 additions & 2 deletions src/PGMS.Desktop/ChangeScriptDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ namespace PGMS.Desktop;
/// <summary>The SQL a designer is about to run. Save requires this review (decision of 06/11/2026); Generate Change Script opens it without Apply, like the SSMS 22.11 Save Change Script.</summary>
public partial class ChangeScriptDialog : Window
{
public ChangeScriptDialog(TableDesignChange change, bool canApply)
/// <param name="intro">Replaces the first line when Apply does not run the script in one transaction.</param>
public ChangeScriptDialog(TableDesignChange change, bool canApply, string? intro = null)
{
InitializeComponent();
Script.Text = change.Sql.Replace("\n", Environment.NewLine, StringComparison.Ordinal);
Intro.Text = canApply ? "Review the change script. Apply runs it in one transaction." : "Do you want to save this change script to a text file?";
Intro.Text = intro ?? (canApply ? "Review the change script. Apply runs it in one transaction." : "Do you want to save this change script to a text file?");
ApplyButton.Visibility = canApply ? Visibility.Visible : Visibility.Collapsed;
if (!canApply) CancelButton.Content = "_Close";
if (change.Warnings.Count > 0) { Warnings.Text = string.Join(Environment.NewLine, change.Warnings); Warnings.Visibility = Visibility.Visible; }
Expand Down
9 changes: 7 additions & 2 deletions src/PGMS.Desktop/DatabaseDiagramModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ public sealed class DiagramTableModel
public double Y { get; set; }
public DiagramTableView View { get; set; }
public List<string> CustomColumns { get; } = [.. DiagramColumnFields.Standard];
/// <summary>The indexes of the table as the catalog has them (PGMS-044): what the Indexes section shows. Pending changes of Indexes/Keys are not here until saved.</summary>
public DiagramTableIndexes Catalog { get; set; } = DiagramTableIndexes.Empty;
/// <summary>The Indexes section is open; it starts closed (decisão do usuário, 11/11/2026).</summary>
public bool IndexesExpanded { get; set; }

public DiagramTableModel(TableDesign design, double x, double y) { Original = design; X = x; Y = y; Reset(design); }

Expand All @@ -63,14 +67,15 @@ public sealed class DiagramTableModel
/// <summary>Made with New Table in this diagram and not saved yet.</summary>
public bool IsNew => Original.Oid == 0;
public IReadOnlyList<string> Fields => View switch { DiagramTableView.Standard => DiagramColumnFields.Standard, DiagramTableView.Custom => CustomColumns, _ => [] };
/// <summary>The rows of the current Table View. Keys shows the columns of the primary key, the unique keys and the foreign keys (inferred).</summary>
/// <summary>The rows of the current Table View. Keys shows the columns of the keys and of every index, as SSMS 22.11 does (pilotagem de 11/11/2026,
/// docs/MARCO-M1061.md: a column used only in the WHERE of a filtered index stays out); the columns of the foreign keys are inferred.</summary>
public IReadOnlyList<DesignColumn> VisibleColumns
{
get
{
if (View == DiagramTableView.NameOnly) return [];
if (View != DiagramTableView.Keys) return Columns;
var keys = Indexes.Where(i => i.Kind != DesignIndexKind.Index).SelectMany(i => i.Columns.Select(c => c.Name)).Concat(ForeignKeys.SelectMany(k => k.Columns)).ToHashSet(StringComparer.Ordinal);
var keys = Indexes.SelectMany(i => i.Columns.Select(c => c.Name)).Concat(ForeignKeys.SelectMany(k => k.Columns)).ToHashSet(StringComparer.Ordinal);
return Columns.Where(c => keys.Contains(c.Name)).ToArray();
}
}
Expand Down
1 change: 1 addition & 0 deletions src/PGMS.Desktop/DatabaseDiagramView.Editing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ private static void ApplyPlacement(DiagramTableModel table, DiagramTablePlacemen
{
if (Enum.TryParse<DiagramTableView>(placement.View, out var view)) table.View = view;
if (placement.CustomColumns is { } custom) { table.CustomColumns.Clear(); table.CustomColumns.AddRange(custom.Where(DiagramColumnFields.All.Contains)); }
table.IndexesExpanded = placement.IndexesExpanded;
}

private Rect[] ContentRects() => tables.Where(boxes.ContainsKey).Select(Bounds).Concat(annotations.Where(noteBoxes.ContainsKey).Select(NoteBounds)).ToArray();
Expand Down
Loading