Skip to content

Commit f4ca978

Browse files
committed
feat: migrate default postgres schema
- Migrate schema from public to stacks-blockchain-api. BREAKING CHANGE: This change will require resyncing from genesis
1 parent 32f879f commit f4ca978

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ PG_PORT=5490
33
PG_USER=postgres
44
PG_PASSWORD=postgres
55
PG_DATABASE=stacks_blockchain_api
6-
PG_SCHEMA=public
6+
PG_SCHEMA=stacks_blockchain_api
77
PG_SSL=false
88
# Idle connection timeout in seconds, defaults to 30
99
# PG_IDLE_TIMEOUT=30

tests/event-replay/import-export.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ describe('import/export tests', () => {
2828

2929
test('event import and export cycle - remote', async () => {
3030
// Import from mocknet TSV
31+
await migrate('up', true);
3132
await importEventsFromTsv('tests/event-replay/tsv/mocknet.tsv', 'archival', true, true);
3233
const chainTip = await db.getChainTip(db.sql);
3334
expect(chainTip.block_height).toBe(28);
@@ -61,6 +62,7 @@ describe('import/export tests', () => {
6162

6263
test('event import and export cycle - local', async () => {
6364
// Import from mocknet TSV
65+
await migrate('up', true);
6466
await importEventsFromTsv('tests/event-replay/tsv/mocknet.tsv', 'archival', true, true);
6567
const chainTip = await db.getChainTip(db.sql);
6668
expect(chainTip.block_height).toBe(28);

tests/utils/test-helpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ import { getConnectionArgs } from '../../src/datastore/connection';
5151
import { AddressStxBalance } from '../../src/api/schemas/entities/addresses';
5252
import { ServerStatusResponse } from '../../src/api/schemas/responses/responses';
5353

54-
export async function migrate(direction: 'up' | 'down') {
54+
export async function migrate(direction: 'up' | 'down', skipMigrations = false) {
5555
const connArgs = getConnectionArgs();
5656
if (typeof connArgs !== 'string' && connArgs.schema) {
5757
const sql = await connectPostgres({
@@ -61,7 +61,7 @@ export async function migrate(direction: 'up' | 'down') {
6161
await sql`CREATE SCHEMA IF NOT EXISTS ${sql(connArgs.schema)}`;
6262
await sql.end();
6363
}
64-
await runMigrations(MIGRATIONS_DIR, direction, connArgs);
64+
if (!skipMigrations) await runMigrations(MIGRATIONS_DIR, direction, connArgs);
6565
}
6666

6767
export interface TestEnvContext {

0 commit comments

Comments
 (0)