Skip to content

Commit 773ac19

Browse files
committed
cleanup based on review
1 parent 5d40ae7 commit 773ac19

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

packages/host/config/environment.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ function getLatestSchemaFile() {
108108
let files = fs.readdirSync(schemaDir);
109109
let latestSchemaFile = files.sort().pop();
110110
if (
111-
lastMigration.replace(/_.*/, '') !== latestSchemaFile.replace(/_.*/, '')
111+
lastMigration.replace(/_.*/, '') !== latestSchemaFile.replace(/_.*/, '') &&
112+
['development', 'test'].includes(process.env.EMBER_ENV)
112113
) {
113114
throw new Error(
114115
`The sqlite schema file is out of date--please regenerate the sqlite schema file`,

packages/realm-server/scripts/convert-to-sqlite.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ let pgDump = readFileSync(pgDumpFile, 'utf8');
3030

3131
let cst = parse(prepareDump(pgDump), {
3232
dialect: 'postgresql',
33-
includeSpaces: true,
34-
includeNewlines: true,
35-
includeComments: true,
36-
includeRange: true,
3733
});
3834

3935
let sql: string[] = [
@@ -122,10 +118,14 @@ function createColumns(
122118

123119
columns.push(column.join(' '));
124120
}
125-
sql.push([...columns, makePrimaryKeyConstraint(cst, tableName)].join(',\n'));
121+
let pkConstraint = makePrimaryKeyConstraint(cst, tableName);
122+
sql.push([...columns, ...(pkConstraint ? [pkConstraint] : [])].join(',\n'));
126123
}
127124

128-
function makePrimaryKeyConstraint(cst: Program, tableName: string): string {
125+
function makePrimaryKeyConstraint(
126+
cst: Program,
127+
tableName: string,
128+
): string | undefined {
129129
let alterTableStmts = cst.statements.filter(
130130
(s) =>
131131
s.type === 'alter_table_stmt' &&
@@ -180,6 +180,9 @@ function makePrimaryKeyConstraint(cst: Program, tableName: string): string {
180180
}
181181
}
182182
}
183+
if (pkConstraint.length === 0) {
184+
return undefined;
185+
}
183186
return pkConstraint.join(' ');
184187
}
185188

0 commit comments

Comments
 (0)