Skip to content

Cannot seed Astro DB when seed file is under srcDir #10712

@kidonng

Description

@kidonng

Astro Info

Astro                    v4.5.16
Node                     v18.18.0
System                   Linux (x64)
Package Manager          unknown
Output                   static
Adapter                  none
Integrations             astro:db
                         @astrojs/db/file-url

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

I prefer to set srcDir: '.' to avoid an extra directory level. However, when using Astro DB, seeding will fail with the following error:

00:13:11 [ERROR] [astro:db] Cannot read properties of undefined (reading 'Symbol(drizzle:Columns)')

As mentioned in #10458 (comment), if I unset srcDir and move the seed file (seed.ts, along with the entire db folder) outside of src, seeding will succeed.

I digged in the code and found if I change it to return resolved.virtual even if the seed file is inside srcDir, the seeding will succeed as well, without "recursive seed calls" as mentioned in the comments. This may have unexpected consequences though since I'm not familiar with the internals.

if (importer.id.startsWith(srcDirPath)) {
// Seed only if the importer is in the src directory.
// Otherwise, we may get recursive seed calls (ex. import from db/seed.ts).
return resolved.seedVirtual;
}
return resolved.virtual;

What's the expected result?

Seeding should success whether the seed file is under srcDir or not.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-tx22uf

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

Labels

- P3: minor bugAn edge case that only affects very specific usage (priority)pkg: db

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions