mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) upgrade typeorm so we can support newer postgres
Summary: upgrade typeorm version, so Grist can run against newer versions of postgres. Dusted off some old benchmarking code to verify that important queries don't get slower. They don't appear to, unlike for some intermediate versions of typeorm I tried in the past. Most of the changes are because `findOne` changed how it interprets its arguments, and the value it returns when nothing is found. For the return value, I stuck with limiting its impact by emulating old behavior (returning undefined rather than null) rather than propagating the change out to parts of the code unrelated to the database. Test Plan: existing tests pass; manual testing with postgres 10 and 14 Reviewers: georgegevoian Reviewed By: georgegevoian Differential Revision: https://phab.getgrist.com/D3613
This commit is contained in:
@@ -428,7 +428,7 @@ class Seed {
|
||||
const ba = new BillingAccount();
|
||||
ba.individual = false;
|
||||
const productName = org.product || 'Free';
|
||||
ba.product = (await Product.findOne({name: productName}))!;
|
||||
ba.product = (await Product.findOne({where: {name: productName}}))!;
|
||||
o.billingAccount = ba;
|
||||
if (org.domain) { o.domain = org.domain; }
|
||||
if (org.host) { o.host = org.host; }
|
||||
@@ -461,7 +461,7 @@ class Seed {
|
||||
}
|
||||
|
||||
public async run() {
|
||||
if (await this.userRepository.findOne()) {
|
||||
if (await this.userRepository.findOne({where: {}})) {
|
||||
// we already have a user - skip seeding database
|
||||
return;
|
||||
}
|
||||
@@ -472,7 +472,7 @@ class Seed {
|
||||
|
||||
// Creates benchmark data with 10 orgs, 50 workspaces per org and 20 docs per workspace.
|
||||
public async runBenchmark() {
|
||||
if (await this.userRepository.findOne()) {
|
||||
if (await this.userRepository.findOne({where: {}})) {
|
||||
// we already have a user - skip seeding database
|
||||
return;
|
||||
}
|
||||
@@ -501,7 +501,7 @@ class Seed {
|
||||
login.displayEmail = login.email = name.toLowerCase() + "@getgrist.com";
|
||||
login.user = user;
|
||||
await login.save();
|
||||
const personal = await Organization.findOne({name: name + "land"});
|
||||
const personal = await Organization.findOne({where: {name: name + "land"}});
|
||||
if (personal) {
|
||||
personal.owner = user;
|
||||
await personal.save();
|
||||
@@ -521,8 +521,8 @@ export async function removeConnection() {
|
||||
throw new Error("unexpected number of connections");
|
||||
}
|
||||
await getConnectionManager().connections[0].close();
|
||||
// There is no official way to delete connections that I've found.
|
||||
(getConnectionManager().connections as any) = [];
|
||||
// There is still no official way to delete connections that I've found.
|
||||
(getConnectionManager() as any).connectionMap = new Map();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -593,6 +593,9 @@ export async function createServer(port: number, initDb = createInitialDb): Prom
|
||||
flexServer.addJsonSupport();
|
||||
await flexServer.start();
|
||||
await flexServer.initHomeDBManager();
|
||||
flexServer.addDocWorkerMap();
|
||||
await flexServer.loadConfig();
|
||||
flexServer.addHosts();
|
||||
flexServer.addAccessMiddleware();
|
||||
flexServer.addApiMiddleware();
|
||||
flexServer.addHomeApi();
|
||||
|
||||
Reference in New Issue
Block a user