// change.js
// --- 100% SECURE DYNAMIC CONSTRAINT HANDLING ---
// Stock Management System (SMS) Configuration Matrix

const tablesSchema = {
  User: {
    id_field: "id",
    fields: {
      username: "VARCHAR(50) UNIQUE NOT NULL",
      password: "VARCHAR(255) NOT NULL"
    }
  },
  Suppliers: {
    id_field: "SupplierCode",
    fields: {
      SupplierName: "VARCHAR(100) NOT NULL",
      ContactPerson: "VARCHAR(100) NOT NULL",
      SupplierPhone: "VARCHAR(20) NOT NULL",
      SupplierEmail: "VARCHAR(100) NOT NULL"
    }
  },
  Products: {
    id_field: "ProductCode",
    fields: {
      ProductName: "VARCHAR(100) NOT NULL",
      Category: "VARCHAR(50) NOT NULL",
      UnitPrice: "INT NOT NULL",
      CurrentStock: "INT NOT NULL DEFAULT 0",
      MinimumRequiredStock: "INT NOT NULL DEFAULT 5"
    }
  },
  StockInbound: {
    id_field: "BatchNumber",
    fields: {
      ProductCode: "VARCHAR(50) NOT NULL",
      SupplierCode: "VARCHAR(50) NOT NULL",
      QuantityReceived: "INT NOT NULL",
      InboundDate: "DATE NOT NULL"
    },
    foreignKeys: [
      { field: "ProductCode", referenceTable: "Products", referenceField: "ProductCode" },
      { field: "SupplierCode", referenceTable: "Suppliers", referenceField: "SupplierCode" }
    ]
  },
  SalesOrder: {
    id_field: "InvoiceNumber",
    fields: {
      BatchNumber: "INT NOT NULL",
      QuantitySold: "INT NOT NULL",
      TotalCostAmount: "INT NOT NULL",
      SalesDate: "DATE NOT NULL"
    },
    foreignKeys: [
      { field: "BatchNumber", referenceTable: "StockInbound", referenceField: "BatchNumber" }
    ]
  }
};

module.exports = {
  dbConfig: {
    host: "localhost",
    user: "root",
    password: "",
    port: 3306
  },
  dbName: "SMS_DB", 
  resetDatabaseOnStart: true, 

  tables: tablesSchema,

  // Default core initial products containing aligned structural categories matching rows
  defaultServices: [
    ["PROD01", "Industrial Grade Engine Oil", "Fluids", 150000],
    ["PROD02", "Heavy Duty Transmission Gear", "Drivetrain", 80000],
    ["PROD03", "Synthetic Lubricant Fluid Pack", "Fluids", 60000],
    ["PROD04", "Alloy Timing Chain Kit", "Engine Parts", 40000],
    ["PROD05", "Ceramic Brake Disc Component", "Brakes", 400000],
    ["PROD06", "Performance Wheel Hub Spacer", "Suspension", 5000]
  ]
};