0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-03-31 23:31:30 -05:00

[ci] format

This commit is contained in:
Fred K. Schott 2024-03-04 10:51:57 +00:00 committed by astrobot-houston
parent 93ec9e264a
commit 51393a729b
8 changed files with 19 additions and 19 deletions

View file

@ -4,9 +4,9 @@ import { getManagedAppTokenOrExit } from '../../../tokens.js';
import { type DBConfig, type DBSnapshot } from '../../../types.js';
import { getRemoteDatabaseUrl } from '../../../utils.js';
import {
getMigrationQueries,
createCurrentSnapshot,
createEmptySnapshot,
getMigrationQueries,
getProductionCurrentSnapshot,
} from '../../migration-queries.js';

View file

@ -1,11 +1,13 @@
import type { AstroConfig } from 'astro';
import type { Arguments } from 'yargs-parser';
import { getManagedAppTokenOrExit } from '../../../tokens.js';
import type { DBConfig } from '../../../types.js';
import { getMigrationQueries,
import {
createCurrentSnapshot,
createEmptySnapshot,
getProductionCurrentSnapshot, } from '../../migration-queries.js';
import { getManagedAppTokenOrExit } from '../../../tokens.js';
getMigrationQueries,
getProductionCurrentSnapshot,
} from '../../migration-queries.js';
export async function cmd({
dbConfig,
@ -19,7 +21,8 @@ export async function cmd({
const productionSnapshot = await getProductionCurrentSnapshot({ appToken: appToken.token });
const currentSnapshot = createCurrentSnapshot(dbConfig);
const { queries: migrationQueries } = await getMigrationQueries({
oldSnapshot: JSON.stringify(productionSnapshot) !== '{}' ? productionSnapshot : createEmptySnapshot(),
oldSnapshot:
JSON.stringify(productionSnapshot) !== '{}' ? productionSnapshot : createEmptySnapshot(),
newSnapshot: currentSnapshot,
});

View file

@ -13,6 +13,7 @@ import {
schemaTypeToSqlType,
} from '../../runtime/queries.js';
import { isSerializedSQL } from '../../runtime/types.js';
import { RENAME_COLUMN_ERROR, RENAME_TABLE_ERROR } from '../errors.js';
import {
type BooleanColumn,
type ColumnType,
@ -30,7 +31,6 @@ import {
columnSchema,
} from '../types.js';
import { getRemoteDatabaseUrl } from '../utils.js';
import { RENAME_COLUMN_ERROR, RENAME_TABLE_ERROR } from '../errors.js';
const sqlite = new SQLiteAsyncDialect();
const genTempTableName = customAlphabet('abcdefghijklmnopqrstuvwxyz', 10);
@ -51,7 +51,10 @@ export async function getMigrationQueries({
);
if (!isEmpty(addedCollections) && !isEmpty(notDeprecatedDroppedTables)) {
throw new Error(
RENAME_TABLE_ERROR(Object.keys(addedCollections)[0], Object.keys(notDeprecatedDroppedTables)[0])
RENAME_TABLE_ERROR(
Object.keys(addedCollections)[0],
Object.keys(notDeprecatedDroppedTables)[0]
)
);
}

View file

@ -22,7 +22,7 @@ const baseColumnSchema = z.object({
optional: z.boolean().optional().default(false),
unique: z.boolean().optional().default(false),
deprecated: z.boolean().optional().default(false),
// Defined when `defineReadableTable()` is called
name: z.string().optional(),
// TODO: rename to `tableName`. Breaking schema change

View file

@ -68,7 +68,7 @@ export async function recreateTables({ db, tables }: { db: SqliteDB; tables: DBT
export function getDropTableIfExistsQuery(tableName: string) {
return `DROP TABLE IF EXISTS ${sqlite.escapeName(tableName)}`;
};
}
export function getCreateTableQuery(tableName: string, table: DBTable) {
let query = `CREATE TABLE ${sqlite.escapeName(tableName)} (`;

View file

@ -4,7 +4,7 @@ import { column, defineDB, defineTable } from 'astro:db';
const Author = defineTable({
columns: {
name: column.text(),
age2: column.number({optional: true}),
age2: column.number({ optional: true }),
},
});

View file

@ -9,7 +9,7 @@ export const Themes = defineTable({
updated: column.date({
default: NOW,
}),
isDark: column.boolean({ default: sql`TRUE`, deprecated: true}),
isDark: column.boolean({ default: sql`TRUE`, deprecated: true }),
owner: column.text({ optional: true, default: sql`NULL` }),
},
});

View file

@ -32,10 +32,7 @@ function userChangeQueries(oldTable, newTable) {
});
}
function configChangeQueries(
oldCollections,
newCollections,
) {
function configChangeQueries(oldCollections, newCollections) {
return getMigrationQueries({
oldSnapshot: { schema: oldCollections, experimentalVersion: 1 },
newSnapshot: { schema: newCollections, experimentalVersion: 1 },
@ -96,10 +93,7 @@ describe('column queries', () => {
});
let error = null;
try {
await configChangeQueries(
{[TABLE_NAME]: blogInitial},
{[TABLE_NAME]: blogFinal},
);
await configChangeQueries({ [TABLE_NAME]: blogInitial }, { [TABLE_NAME]: blogFinal });
} catch (e) {
error = e.message;
}