-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed as not planned
Labels
- P4: importantViolate documented behavior or significantly impacts performance (priority)Violate documented behavior or significantly impacts performance (priority)pkg: db
Description
Astro Info
Astro v4.7.0
Node v20.12.2
System macOS (arm64)
Package Manager npm
Output server
Adapter @astrojs/vercel/serverless
Integrations @astrojs/react
@astrojs/tailwind
astro-auth
astro:db
@astrojs/db/file-url
astro-icon
If this issue only occurs in one browser, which browser is a problem?
cli
Describe the Bug
I have this schema but i receive a error
Database schema is out of date. Pushing database schema updates... https://db.services.astro.build/db/push failed: 400 Bad Request {"success":false,"error":{"code":"SQL_QUERY_FAILED","details":"SQLITE_CONSTRAINT: SQLite error: FOREIGN KEY constraint failed"}} /db/push fetch failed: 400 Bad Request
import { column, defineDb } from 'astro:db'
const Users = {
columns: {
userName: column.text(),
userEmail: column.text({ primaryKey: true }),
userImage: column.text({ optional: true }),
createdAt: column.date({ default: new Date() }),
lastVisit: column.date({ default: new Date() }),
accountType: column.text({ default: 'free' }),
accountProvider: column.text({ default: 'email' }),
userPassword: column.text({ optional: true }),
userStatus: column.number({ default: 1 }),
credits: column.number({ default: 5 }),
notes: column.text({ optional: true })
}
}
const Recipes = {
columns: {
id: column.number({ primaryKey: true }),
prompt: column.text(),
tokens: column.text(),
result: column.text(),
user: column.text({ references: () => Users.columns.userEmail }),
createdAt: column.date({ default: new Date() }),
favorite: column.boolean({ default: false }),
rating: column.number({ default: 0 }),
status: column.number({ default: 1 }),
modelVersion: column.text(),
slug: column.text({ unique: true })
}
}
const Settings = {
columns: {
id: column.number({ primaryKey: true }),
user: column.text({ references: () => Users.columns.userEmail }),
languageResponse: column.text({ default: 'spanish' }),
measurement: column.text({ default: 'international' }),
vegetarian: column.boolean({ default: false }),
vegan: column.boolean({ default: false }),
keto: column.boolean({ default: false }),
sugarfree: column.boolean({ default: false }),
glutenfree: column.boolean({ default: false }),
notificationsEmail: column.boolean({ default: true }),
notificationsPush: column.boolean({ default: true }),
theme: column.text({ default: 'default' })
}
}
export default defineDb({
tables: {
Users,
Recipes,
Settings
}
})What's the expected result?
a clean push to studio
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-rjvwlr
Participation
- I am willing to submit a pull request for this issue.
Metadata
Metadata
Assignees
Labels
- P4: importantViolate documented behavior or significantly impacts performance (priority)Violate documented behavior or significantly impacts performance (priority)pkg: db