Skip to content

Commit

Permalink
Cleaning up some leftovers from #7836
Browse files Browse the repository at this point in the history
  • Loading branch information
joehan committed Nov 21, 2024
1 parent 0f45706 commit dc4ced6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 21 deletions.
8 changes: 0 additions & 8 deletions firebase-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,6 @@
}
}
},
"keybindings": [
{
"command": "firebase.dataConnect.executeOperationAtCursor",
"key": "ctrl+enter",
"mac": "cmd+enter",
"when": "editorLangId == gql || editorLangId == graphql"
}
],
"viewsContainers": {
"activitybar": [
{
Expand Down
23 changes: 12 additions & 11 deletions src/emulator/dataconnect/pgliteServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ import {
} from "./pg-gateway/index";
import { fromNodeSocket } from "./pg-gateway/platforms/node";
import { logger } from "../../logger";
export const TRUNCATE_TABLES_SQL = `
DO $do$
BEGIN
EXECUTE
(SELECT 'TRUNCATE TABLE ' || string_agg(oid::regclass::text, ', ') || ' CASCADE'
FROM pg_class
WHERE relkind = 'r'
AND relnamespace = 'public'::regnamespace
);
END
$do$;`;

export class PostgresServer {
private username: string;
Expand Down Expand Up @@ -95,17 +106,7 @@ export class PostgresServer {

public async clearDb(): Promise<void> {
const db = await this.getDb();
await db.query(`
DO $do$
BEGIN
EXECUTE
(SELECT 'TRUNCATE TABLE ' || string_agg(oid::regclass::text, ', ') || ' CASCADE'
FROM pg_class
WHERE relkind = 'r'
AND relnamespace = 'public'::regnamespace
);
END
$do$;`);
await db.query(TRUNCATE_TABLES_SQL);
}

public async exportData(exportPath: string): Promise<void> {
Expand Down
6 changes: 5 additions & 1 deletion src/emulator/dataconnectEmulator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as childProcess from "child_process";
import * as pg from "pg";
import { EventEmitter } from "events";
import * as clc from "colorette";
import * as path from "path";
Expand All @@ -17,7 +18,7 @@ import { EmulatorRegistry } from "./registry";
import { logger } from "../logger";
import { load } from "../dataconnect/load";
import { Config } from "../config";
import { PostgresServer } from "./dataconnect/pgliteServer";
import { PostgresServer, TRUNCATE_TABLES_SQL } from "./dataconnect/pgliteServer";
import { cleanShutdown } from "./controller";
import { connectableHostname } from "../utils";

Expand Down Expand Up @@ -180,6 +181,9 @@ export class DataConnectEmulator implements EmulatorInstance {
async clearData(): Promise<void> {
if (this.postgresServer) {
await this.postgresServer.clearDb();
} else {
const conn = new pg.Client(dataConnectLocalConnString());
conn.query(TRUNCATE_TABLES_SQL);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/emulator/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const DOWNLOADABLE_EMULATORS = [
Emulators.DATACONNECT,
];

export type ImportExportEmulators = Emulators.FIRESTORE | Emulators.DATABASE | Emulators.AUTH;
export type ImportExportEmulators = Emulators.FIRESTORE | Emulators.DATABASE | Emulators.AUTH | Emulators.STORAGE | Emulators.DATACONNECT;
export const IMPORT_EXPORT_EMULATORS = [
Emulators.FIRESTORE,
Emulators.DATABASE,
Expand Down

0 comments on commit dc4ced6

Please sign in to comment.