Skip to content
Merged
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
197 changes: 0 additions & 197 deletions MIGRATION.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ procedures/verify_table_grant [procedures/get_entity_from_str procedures/get_sch
procedures/verify_table [procedures/get_entity_from_str procedures/get_schema_from_str] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add procedures/verify_table
procedures/verify_trigger [procedures/get_entity_from_str procedures/get_schema_from_str] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add procedures/verify_trigger
procedures/verify_type [procedures/get_entity_from_str procedures/get_schema_from_str] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add procedures/verify_type
procedures/verify_view [procedures/get_entity_from_str procedures/get_schema_from_str] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add procedures/verify_view
procedures/verify_view [procedures/get_entity_from_str procedures/get_schema_from_str] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add procedures/verify_view
@0.1.0 2025-08-26T23:56:48Z launchql <launchql@5b0c196eeb62> # verify
2 changes: 1 addition & 1 deletion __fixtures__/stage/packages/unique-names/launchql.plan
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
%project=unique-names
%uri=unique-names

schemas/unique_names/schema [launchql-ext-default-roles:@0.0.5 launchql-ext-defaults:defaults/public launchql-ext-verify:procedures/verify_view] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/unique_names/schema
schemas/unique_names/schema [launchql-ext-default-roles:@0.0.5 launchql-ext-defaults:defaults/public launchql-ext-verify:@0.1.0] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/unique_names/schema
schemas/unique_names/tables/words/table [schemas/unique_names/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/unique_names/tables/words/table
schemas/unique_names/procedures/generate_name [schemas/unique_names/schema schemas/unique_names/tables/words/table] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/unique_names/procedures/generate_name
schemas/unique_names/tables/words/fixtures/1589271124916_fixture [schemas/unique_names/schema schemas/unique_names/tables/words/table] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/unique_names/tables/words/fixtures/1589271124916_fixture
Expand Down
47 changes: 47 additions & 0 deletions packages/cli/__tests__/cli-deploy-stage-unique-names.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { CLIDeployTestFixture } from '../test-utils';

jest.setTimeout(30000);

afterAll(async () => {
const { teardownPgPools } = require('pg-cache');
await teardownPgPools();
});

describe('CLIDeployTestFixture Migrate', () => {
let fixture: CLIDeployTestFixture;
let testDb: any;

beforeAll(async () => {
fixture = new CLIDeployTestFixture('stage')
testDb = await fixture.setupTestDatabase()
});

afterAll(async () => {
await fixture.cleanup();
});


it('should emulate terminal commands with database operations', async () => {
const terminalCommands = `
lql deploy --recursive --database ${testDb.name} --yes --no-usePlan --package unique-names
`;

const results = await fixture.runTerminalCommands(terminalCommands, {
database: testDb.name
}, true);

expect(results).toHaveLength(1);
});

it('should emulate terminal commands with database operations usePlan', async () => {
const terminalCommands = `
lql deploy --recursive --database ${testDb.name} --yes --usePlan --package unique-names
`;

const results = await fixture.runTerminalCommands(terminalCommands, {
database: testDb.name
}, true);

expect(results).toHaveLength(1);
});
});
10 changes: 5 additions & 5 deletions packages/cli/src/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ export default async (
const cliOverrides = {
pg: getPgEnvOptions({ database }),
deployment: {
useTx: tx,
fast,
usePlan: argv.usePlan,
cache: argv.cache,
logOnly
useTx: tx !== false,
fast: fast !== false,
usePlan: argv.usePlan !== false,
cache: argv.cache !== false,
logOnly: argv.logOnly !== false,
}
};

Expand Down
6 changes: 2 additions & 4 deletions packages/cli/src/commands/plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,14 @@ export default async (
name: 'includePackages',
message: 'Include packages in plan?',
useDefault: true,
default: true,
when: (_a) => typeof argv.includePackages === 'undefined'
default: true
},
{
type: 'confirm',
name: 'includeTags',
message: 'Prefer @tag references for external packages when available?',
useDefault: true,
default: true,
when: (_a) => typeof argv.includeTags === 'undefined'
default: true
}
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ exports[`stage fixture plan generation (unique-names) generates a plan for uniqu
"%syntax-version=1.0.0
%project=unique-names
%uri=unique-names
schemas/unique_names/schema [launchql-ext-default-roles:@0.0.5 launchql-ext-defaults:defaults/public launchql-ext-verify:procedures/verify_view] 2017-08-11T08:11:51Z launchql <launchql@5b0c196eeb62> # add schemas/unique_names/schema
schemas/unique_names/schema [launchql-ext-default-roles:@0.0.5 launchql-ext-defaults:defaults/public launchql-ext-verify:@0.1.0] 2017-08-11T08:11:51Z launchql <launchql@5b0c196eeb62> # add schemas/unique_names/schema
schemas/unique_names/tables/words/table [schemas/unique_names/schema] 2017-08-11T08:11:51Z launchql <launchql@5b0c196eeb62> # add schemas/unique_names/tables/words/table
schemas/unique_names/tables/words/indexes/words_type_idx [schemas/unique_names/schema schemas/unique_names/tables/words/table] 2017-08-11T08:11:51Z launchql <launchql@5b0c196eeb62> # add schemas/unique_names/tables/words/indexes/words_type_idx
schemas/unique_names/tables/words/fixtures/1589271124916_fixture [schemas/unique_names/schema schemas/unique_names/tables/words/table] 2017-08-11T08:11:51Z launchql <launchql@5b0c196eeb62> # add schemas/unique_names/tables/words/fixtures/1589271124916_fixture
Expand Down
70 changes: 70 additions & 0 deletions packages/core/__tests__/migrate/tag-fallback.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { mkdtempSync, writeFileSync, mkdirSync } from 'fs';
import { tmpdir } from 'os';
import { join } from 'path';

jest.mock('../../src/migrate/utils/transaction', () => ({
withTransaction: async (_pool: any, _opts: any, fn: any) => fn({}),
executeQuery: jest.fn().mockResolvedValue(undefined),
}));

jest.mock('../../src/resolution/deps', () => ({
resolveDependencies: (): any => ({
deps: {
'/deploy/schemas_unique_names_schema.sql': [],
},
}),
}));

jest.mock('pg-cache', () => ({
getPgPool: () => ({
query: jest
.fn()
.mockImplementation((sql: string, params?: any[]) => {
if (typeof sql === 'string' && sql.includes('SELECT EXISTS')) {
return Promise.resolve({ rows: [{ exists: true }] });
}
if (typeof sql === 'string' && sql.includes('SELECT launchql_migrate.is_deployed')) {
return Promise.resolve({ rows: [{ is_deployed: false }] });
}
return Promise.resolve({ rows: [] });
}),
}),
}));

import { LaunchQLMigrate } from '../../src/migrate/client';
import { executeQuery } from '../../src/migrate/utils/transaction';

describe('LaunchQLMigrate.deploy tag fallback bug reproduction', () => {
it('should not pass tag tokens when resolver returns an empty deps array (expected behavior after fix)', async () => {
const dir = mkdtempSync(join(tmpdir(), 'lql-core-test-'));
const packageName = 'unique-names';
const changeName = 'schemas_unique_names_schema';

const plan = [
`%project=${packageName}`,
`${changeName} [launchql-ext-default-roles:@0.0.5]`,
].join('\n');

mkdirSync(join(dir, 'deploy'), { recursive: true });
writeFileSync(join(dir, 'launchql.plan'), plan);
writeFileSync(join(dir, 'deploy', `${changeName}.sql`), 'select 1;');

const migrator = new LaunchQLMigrate(
{ host: 'localhost', port: 5432, user: 'postgres', database: 'postgres' } as any,
{}
);

await migrator.deploy({
modulePath: dir,
useTransaction: false,
logOnly: true,
} as any);

const calls = (executeQuery as jest.Mock).mock.calls;
expect(calls.length).toBeGreaterThan(0);
const params = calls[0][2];
const deps = params[3];

expect(deps).toBeNull();
});
});
4 changes: 2 additions & 2 deletions packages/core/__tests__/migration/basic-deployment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ describe('Deploy Command', () => {

// Verify dependencies were recorded
const tableDeps = await db.getDependencies('test-simple', 'table');
expect(tableDeps).toContain('schema');
expect(tableDeps).toContain('test-simple:schema');

const indexDeps = await db.getDependencies('test-simple', 'index');
expect(indexDeps).toContain('table');
expect(indexDeps).toContain('test-simple:table');
});

test('skips already deployed changes', async () => {
Expand Down
Loading