Skip to content

Commit 4ed856e

Browse files
bplunkett-stripealeclarson
authored andcommitted
Add support for Postgres17 (+ misc linting changes) (stripe#187)
1 parent 85460c4 commit 4ed856e

File tree

13 files changed

+35
-22
lines changed

13 files changed

+35
-22
lines changed

.github/workflows/run-tests.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,19 @@ jobs:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
pg_package: ["postgresql14", "postgresql15", "postgresql16"]
13+
include:
14+
- base_image: "golang:1.20.14-alpine3.19"
15+
pg_package: "postgresql14"
16+
- base_image: "golang:1.20.14-alpine3.19"
17+
pg_package: "postgresql15"
18+
- base_image: "golang:1.20.14-alpine3.19"
19+
pg_package: "postgresql16"
20+
- base_image: "golang:1.22.10-alpine3.21"
21+
pg_package: "postgresql17"
1422
steps:
1523
- name: Checkout code
1624
uses: actions/checkout@v3
1725
- name: Build Docker image
18-
run: docker build -t pg-schema-diff-test-runner -f ./build/Dockerfile.test --build-arg POSTGRES_PACKAGE=${{ matrix.pg_package }} .
26+
run: docker build -t pg-schema-diff-test-runner -f ./build/Dockerfile.test --build-arg BASE_IMAGE=${{ matrix.base_image }} --build-arg POSTGRES_PACKAGE=${{ matrix.pg_package }} .
1927
- name: Run tests
2028
run: docker run pg-schema-diff-test-runner

.golangci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
linters:
22
disable-all: true
33
enable:
4+
- gofmt
45
- goimports
56
- ineffassign
67
- staticcheck

build/Dockerfile.lint

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ RUN wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master
1111
# Install sqlfluff
1212
RUN pip install wheel # It complains if we attempt to install this in the same command as Cython
1313
RUN pip install "Cython<3.0" pyyaml --no-build-isolation # Fix for https://github.com/yaml/pyyaml/issues/601
14-
RUN pip install "sqlfluff==2.1.2"
14+
RUN pip install "sqlfluff==3.3.0"
1515

1616
WORKDIR /pg-schema-diff
1717
COPY . .

build/Dockerfile.test

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
FROM golang:1.20.14-alpine3.19
1+
ARG BASE_IMAGE=golang:1.20.14-alpine3.19
22

3-
ARG POSTGRES_PACKAGE=postgresql14
3+
FROM $BASE_IMAGE
44

5+
ARG POSTGRES_PACKAGE=postgresql14
56
RUN apk update && \
67
apk add --no-cache \
78
build-base \

internal/graph/graph.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func (g *Graph[V]) HasVertexWithId(id string) bool {
8888
// Reverse reverses the edges of the map. The sources become the sinks and vice versa.
8989
func (g *Graph[V]) Reverse() {
9090
reversedEdges := make(AdjacencyMatrix)
91-
for vertexId, _ := range g.verticesById {
91+
for vertexId := range g.verticesById {
9292
reversedEdges[vertexId] = make(map[string]bool)
9393
}
9494
for source, adjacentEdgesMap := range g.edges {

internal/graph/graph_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func TestCopy(t *testing.T) {
136136
"shared_1", "shared_2", "shared_3", "g_1", "g_2", "g_3",
137137
})
138138

139-
// validate overrides weren't copied over and non-overriden shared nodes are the same
139+
// validate overrides weren't copied over and non-overridden shared nodes are the same
140140
assert.NotEqual(t, g.GetVertex("shared_1"), gC.GetVertex("shared_1"))
141141
assert.Equal(t, gC.GetVertex("shared_1"), copyOverrideShared1)
142142
assert.NotEqual(t, g.GetVertex("shared_2"), gC.GetVertex("shared_2"))
@@ -425,7 +425,7 @@ func (v vertex) GetId() string {
425425

426426
func getVertexIds(g *Graph[vertex]) []string {
427427
var output []string
428-
for id, _ := range g.verticesById {
428+
for id := range g.verticesById {
429429
output = append(output, id)
430430
}
431431
return output

internal/migration_acceptance_tests/sequence_cases_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ var sequenceAcceptanceTests = []acceptanceTestCase{
200200
},
201201
},
202202
{
203-
name: "And and Drop sequences (conflicing schemas)",
203+
name: "And and Drop sequences (conflicting schemas)",
204204
oldSchemaDDL: []string{
205205
`
206206
CREATE SCHEMA schema_1;

internal/queries/queries.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ WHERE
342342
AND seq_ns.nspname !~ '^pg_temp'
343343
-- Exclude sequences owned by identity columns.
344344
-- These manifest as internal dependency on the column
345-
AND (depend.deptype IS NULL OR depend.deptype != 'i')
345+
AND (depend.deptype IS null OR depend.deptype != 'i')
346346
-- Exclude sequences belonging to extensions
347347
AND NOT EXISTS (
348348
SELECT ext_depend.objid

internal/queries/queries.sql.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/schema/schema.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,8 @@ func (s *schemaFetcher) buildTable(
865865
}
866866

867867
var identity *ColumnIdentity
868-
if len(column.IdentityType) > 0 {
868+
if len(column.IdentityType) > 0 && table.ParentTableName == "" {
869+
// Exclude identity columns from table partitions because they are owned by the parent.
869870
identity = &ColumnIdentity{
870871
Type: ColumnIdentityType(column.IdentityType),
871872
StartValue: column.StartValue.Int64,

0 commit comments

Comments
 (0)