diff options
| author | Alberto Duarte Delgado <alberto@albertoduarte.com> | 2026-04-01 00:56:41 +0100 |
|---|---|---|
| committer | Alberto Duarte Delgado <alberto@albertoduarte.com> | 2026-04-01 00:56:41 +0100 |
| commit | bd4a70dab890153617cad4e0be1364941993d51d (patch) | |
| tree | 5242c256c3e96f8768b29907716fb1274eb9c1fb /src/db | |
| parent | dac9dc1ae6b3531c93801360147100950a103692 (diff) | |
firestore rules y logica de cancelación de reservas
Diffstat (limited to 'src/db')
| -rw-r--r-- | src/db/schema.ts | 73 |
1 files changed, 41 insertions, 32 deletions
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], + }), +})); |