From bd4a70dab890153617cad4e0be1364941993d51d Mon Sep 17 00:00:00 2001 From: Alberto Duarte Delgado Date: Wed, 1 Apr 2026 00:56:41 +0100 Subject: firestore rules y logica de cancelación de reservas MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/db/schema.ts | 73 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 41 insertions(+), 32 deletions(-) (limited to 'src/db') diff --git a/src/db/schema.ts b/src/db/schema.ts index 322d78d..d15bea8 100644 --- a/src/db/schema.ts +++ b/src/db/schema.ts @@ -1,43 +1,52 @@ -; import { relations } from 'drizzle-orm'; -import { integer, real, sqliteTable, text } from 'drizzle-orm/sqlite-core'; -export const personas = sqliteTable('personas', { - id: integer('id').primaryKey({ autoIncrement: true }), - nombre: text('nombre').notNull(), - edad: integer('edad'), -}); - - - - -/* -export const categorias = sqliteTable('categorias', { - id: integer('id').primaryKey({ autoIncrement: true }), - nombre: text('nombre').unique().notNull(), - +import { integer, sqliteTable, text } from 'drizzle-orm/sqlite-core'; +export const users = sqliteTable('users', { + uid: text('uid').primaryKey(), + email: text('email').notNull(), + displayName: text('display_name').notNull(), + photoURL: text('photo_url'), }); - -export const productos = sqliteTable('productos', { - id: integer('id').primaryKey({ autoIncrement: true }), - nombre: text('nombre').unique().notNull(), - stock: integer('stock'), - precio: real('precio'), - categoriaId: integer('categoria_id').references(() => categorias.id), +export const offices = sqliteTable('offices', { + id: text('id').primaryKey(), + name: text('name').notNull(), + location: text('location').notNull(), + capacity: integer('capacity').notNull(), + description: text('description'), }); +export const reservations = sqliteTable('reservations', { + id: text('id').primaryKey(), + officeId: text('office_id') + .notNull() + .references(() => offices.id), + userId: text('user_id') + .notNull() + .references(() => users.uid), + officeName: text('office_name').notNull(), + userEmail: text('user_email').notNull(), + date: text('date').notNull(), + startTime: text('start_time').notNull(), + endTime: text('end_time').notNull(), + createdAt: integer('created_at'), +}); - -export const categoriasRelations = relations(categorias, ({ many }) => ({ - productos: many(productos), +export const usersRelations = relations(users, ({ many }) => ({ + reservations: many(reservations), })); -export const productosRelations = relations(productos, ({ one }) => ({ - pais: one(categorias, { - fields: [productos.categoriaId], - references: [categorias.id], - }), +export const officesRelations = relations(offices, ({ many }) => ({ + reservations: many(reservations), })); -*/ \ No newline at end of file +export const reservationsRelations = relations(reservations, ({ one }) => ({ + office: one(offices, { + fields: [reservations.officeId], + references: [offices.id], + }), + user: one(users, { + fields: [reservations.userId], + references: [users.uid], + }), +})); -- cgit v1.2.3-54-g00ecf