Skip to content

Commit

Permalink
Support a wider range of peer versions of pg (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shpota committed Mar 25, 2023
1 parent 7133ff3 commit ef7fb9b
Show file tree
Hide file tree
Showing 8 changed files with 973 additions and 610 deletions.
1,532 changes: 946 additions & 586 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "podil",
"version": "0.3.3",
"version": "0.3.4",
"description": "Lightweight and secure database migration tool",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
Expand Down Expand Up @@ -41,19 +41,19 @@
"homepage": "https://github.com/podiljs/podil#readme",
"devDependencies": {
"@types/mocha": "^10.0.1",
"@types/pg": "^8.6.5",
"@typescript-eslint/eslint-plugin": "^5.46.1",
"eslint": "^8.29.0",
"eslint-config-standard-with-typescript": "^24.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-n": "^15.6.0",
"@types/pg": "^8.6.6",
"@typescript-eslint/eslint-plugin": "^5.56.0",
"eslint": "^8.36.0",
"eslint-config-standard-with-typescript": "^34.0.1",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-n": "^15.6.1",
"eslint-plugin-promise": "^6.1.1",
"mocha": "^10.2.0",
"testcontainers": "^9.1.1",
"testcontainers": "^9.3.0",
"ts-node": "^10.9.1",
"typescript": "^4.9.4"
"typescript": "^5.0.2"
},
"peerDependencies": {
"pg": "^8.8.0"
"pg": "*"
}
}
6 changes: 3 additions & 3 deletions src/Podil.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { PgMigration } from './db/PgMigration'
import path from 'path'
import fs from 'fs'
import { Script } from './db/Script'
import type { Script } from './db/Script'
import crypto from 'crypto'
import { Migration } from './db/Migration'
import { PodilConfig } from './PodilConfig'
import type { Migration } from './db/Migration'
import type { PodilConfig } from './PodilConfig'

export class Podil {
async migrate (connectionUrl: string, config?: PodilConfig): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion src/db/Migration.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Script } from './Script'
import type { Script } from './Script'

export interface Migration {
connect: () => Promise<void>
Expand Down
4 changes: 2 additions & 2 deletions src/db/PgMigration.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Client } from 'pg'
import { Script } from './Script'
import { Migration } from './Migration'
import type { Script } from './Script'
import type { Migration } from './Migration'

export class PgMigration implements Migration {
private readonly client: Client
Expand Down
10 changes: 7 additions & 3 deletions test/PgMigrationTest.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { StartedTestContainer } from 'testcontainers/dist/test-container'
import { initDatabase } from './config'
import { Client } from 'pg'
import assert from 'assert'
import { PgMigration } from '../src/db/PgMigration'
import type { StartedTestContainer } from 'testcontainers'

describe('PgMigration', async () => {
let container: StartedTestContainer
Expand All @@ -22,9 +22,13 @@ describe('PgMigration', async () => {
await client.query('DROP TABLE IF EXISTS execute_script_test')
})

afterEach('Close connection', async () => await client.end())
afterEach('Close connection', async () => {
await client.end()
})

after('Stop DB', async () => await container.stop())
after('Stop DB', async () => {
await container.stop()
})

it('initializeMetaTable', async () => {
const migration = new PgMigration(connectionString)
Expand Down
6 changes: 3 additions & 3 deletions test/PodilTest.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { StartedTestContainer } from 'testcontainers/dist/test-container'
import { initDatabase } from './config'
import { podil } from '../src'
import { Client } from 'pg'
import assert from 'assert'
import type { StartedTestContainer } from 'testcontainers'

describe('Podil', async () => {
let container: StartedTestContainer
Expand All @@ -15,7 +15,7 @@ describe('Podil', async () => {
connectionString = config.connectionString
})

after('Stop DB container', async () => await container.stop())
after('Stop DB container', async () => { await container.stop() })

beforeEach('Init connection and drop all tables', async () => {
client = new Client({ connectionString })
Expand All @@ -24,7 +24,7 @@ describe('Podil', async () => {
await client.query('DROP TABLE IF EXISTS test_table')
})

afterEach('Close connection', async () => await client.end())
afterEach('Close connection', async () => { await client.end() })

it('should apply migration', async () => {
// when
Expand Down
3 changes: 1 addition & 2 deletions test/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { StartedTestContainer } from 'testcontainers/dist/test-container'
import { GenericContainer } from 'testcontainers'
import { GenericContainer, type StartedTestContainer } from 'testcontainers'

export async function initDatabase (): Promise<{
container: StartedTestContainer
Expand Down

0 comments on commit ef7fb9b

Please sign in to comment.