// Export all schemas
export * from "./enums";
export * from "./servers";
export * from "./apps";
export * from "./companies";
export * from "./branches";
export * from "./users";
export * from "./userBranches";
export * from "./serverSessions";
export * from "./authSessions";
export * from "./protectedRoutes";

// Relations (defined here to avoid circular dependencies)
import { relations } from "drizzle-orm";
import { companies } from "./companies";
import { branches } from "./branches";
import { userBranches } from "./userBranches";

export const companiesRelations = relations(companies, ({ many }) => ({
  branches: many(branches),
}));

export const branchesRelations = relations(branches, ({ one, many }) => ({
  company: one(companies, {
    fields: [branches.companyId],
    references: [companies.id],
  }),
  userBranches: many(userBranches),
}));