Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3c19e9c
fix: move recreateTables() to integration hooks
bholmesdev Apr 30, 2024
4427383
feat: recreate and seed at load, not in virtual runtime
bholmesdev Apr 30, 2024
333131b
feat: eager build db on startup and seed file change
bholmesdev Apr 30, 2024
2c6de6b
fix: respect database_file in dbUrl
bholmesdev Apr 30, 2024
56c4c97
chore: remove duplicate recreateTables call
bholmesdev Apr 30, 2024
82ad425
chore: remove now self-explanatory comments
bholmesdev Apr 30, 2024
a901140
fix: remove invalidateModule call for eager loading
bholmesdev Apr 30, 2024
69b1f77
feat: respect seed package paths
bholmesdev Apr 30, 2024
4abe41d
fix: remove duplicate recreateTables() call
bholmesdev Apr 30, 2024
1ed4c02
refactor: move recreateTables() to vite-plugin-db
bholmesdev Apr 30, 2024
4694c8e
refactor: move queries.ts from runtime/ to core/
bholmesdev Apr 30, 2024
98b1491
fix: update test import to core/queries
bholmesdev Apr 30, 2024
026062e
refactor: move executeSeedFile to vite-plugin-db
bholmesdev Apr 30, 2024
fe7a947
refactor: extract seeding and recreating to helper fns
bholmesdev Apr 30, 2024
c15b585
chore: changeset
bholmesdev Apr 30, 2024
533edb2
chore: revert connectToStudio refactor
bholmesdev Apr 30, 2024
d8b46db
wip: log db url
bholmesdev Apr 30, 2024
6f6fef2
fix(test): normalize astro_database_file flag for windows
bholmesdev Apr 30, 2024
01cca1c
Revert "wip: log db url"
bholmesdev Apr 30, 2024
53ed848
Revert "Revert "wip: log db url""
bholmesdev Apr 30, 2024
33747cb
fix: correctly resolve relative paths with unit test
bholmesdev Apr 30, 2024
a390dbd
chore: remove unused dbDirPath
bholmesdev May 1, 2024
f81cf8b
chore: remove unused import
bholmesdev May 1, 2024
9ba3d60
chore: remove unused type
bholmesdev May 1, 2024
1b41be4
fix: remove bad import
bholmesdev May 2, 2024
3b014fd
[db] Load seed files with vite dev server (#10941)
bholmesdev May 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: correctly resolve relative paths with unit test
  • Loading branch information
bholmesdev committed May 2, 2024
commit 33747cb8d7aba4f627d20d1132773232a51c695e
1 change: 0 additions & 1 deletion packages/db/src/core/integration/vite-plugin-db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ const sqlite = new SQLiteAsyncDialect();
async function recreateTables({ tables, root }: { tables: LateTables; root: URL }) {
const { ASTRO_DATABASE_FILE } = getAstroEnv();
const dbUrl = normalizeDatabaseUrl(ASTRO_DATABASE_FILE, new URL(DB_PATH, root).href);
console.log('recreating:::', dbUrl, ASTRO_DATABASE_FILE, new URL(DB_PATH, root).href);
const db = createLocalDatabaseClient({ dbUrl });
const setupQueries: SQL[] = [];
for (const [name, table] of Object.entries(tables.get() ?? {})) {
Expand Down
2 changes: 1 addition & 1 deletion packages/db/src/runtime/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from 'drizzle-orm/sqlite-core';
import type { DBColumn, DBTable } from '../core/types.js';
import { type SerializedSQL, isSerializedSQL } from './types.js';
import { pathToFileURL } from './utils.js';
import { addTrailingSlash, pathToFileURL } from './utils.js';

export type { Table } from './types.js';
export { createRemoteDatabaseClient, createLocalDatabaseClient } from './db-client.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/db/src/runtime/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class AstroDbError extends AstroError {
name = 'Astro DB Error';
}

export default function slash(path: string) {
function slash(path: string) {
const isExtendedLengthPath = path.startsWith('\\\\?\\');

if (isExtendedLengthPath) {
Expand Down
9 changes: 5 additions & 4 deletions packages/db/test/local-prod.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { fileURLToPath } from 'url';
import { expect } from 'chai';
import testAdapter from '../../astro/test/test-adapter.js';
import { loadFixture } from '../../astro/test/test-utils.js';
import { normalizePath } from 'vite';
import { relative } from 'path';

describe('astro:db local database', () => {
let fixture;
Expand Down Expand Up @@ -33,9 +33,10 @@ describe('astro:db local database', () => {
});
});

describe('build (not remote) with DATABASE_FILE env (file path)', () => {
// env flag should be set with forward slashes. Normalize for windows.
const prodDbPath = normalizePath(fileURLToPath(new URL('./fixtures/basics/dist/astro.db', import.meta.url)));
describe('build (not remote) with DATABASE_FILE env (relative file path)', () => {
const absoluteFileUrl = new URL('./fixtures/basics/dist/astro.db', import.meta.url);
const prodDbPath = relative(process.cwd(), fileURLToPath(absoluteFileUrl));

before(async () => {
process.env.ASTRO_DATABASE_FILE = prodDbPath;
await fixture.build();
Expand Down