Sindbad~EG File Manager

Current Path : /home/infinitibizsol/.trash/
Upload File :
Current File : /home/infinitibizsol/.trash/20240418105121-restric-forgien-key.js

"use strict";

/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up(queryInterface, Sequelize) {
    await queryInterface.addConstraint("tblVehicles", {
      fields: ["user_id"],
      type: "foreign key",
      name: "restrict_user_fkey", // optional: give a custom name
      references: {
        table: "tblUsers",
        field: "user_id",
      },
      onDelete: "RESTRICT",
      onUpdate: "CASCADE",
    });

    await queryInterface.addConstraint("tblVehicleRuns", {
      fields: ["vehicle_id"],
      type: "foreign key",
      name: "restrict_vehicle_fkey", // optional: give a custom name
      references: {
        table: "tblVehicles",
        field: "vehicle_id",
      },
      onDelete: "RESTRICT",
      onUpdate: "CASCADE",
    });

    await queryInterface.addConstraint("tblVehicleRuns", {
      fields: ["lane_id"],
      type: "foreign key",
      name: "restrict_lane_fkey", // optional: give a custom name
      references: {
        table: "tblAuctionLanes",
        field: "lane_id",
      },
      onDelete: "RESTRICT",
      onUpdate: "CASCADE",
    });

    await queryInterface.addConstraint("tblVehicleRuns", {
      fields: ["opportunity_id"],
      type: "foreign key",
      name: "restrict_opportunity_fkey", // optional: give a custom name
      references: {
        table: "tblOpportunities",
        field: "opportunity_id",
      },
      onDelete: "RESTRICT",
      onUpdate: "CASCADE",
    });

    await queryInterface.addConstraint("tblVehicleImages", {
      fields: ["vehicle_id"],
      type: "foreign key",
      name: "restrict_imgvehicle_fkey", // optional: give a custom name
      references: {
        table: "tblVehicles",
        field: "vehicle_id",
      },
      onDelete: "RESTRICT",
      onUpdate: "CASCADE",
    });

    await queryInterface.addConstraint("tblAuctionLanes", {
      fields: ["auctioneer_id"],
      type: "foreign key",
      name: "restrict_auctioneer_fkey", // optional: give a custom name
      references: {
        table: "tblAuctioneers",
        field: "auctioneer_id",
      },
      onDelete: "RESTRICT",
      onUpdate: "CASCADE",
    });

    await queryInterface.addConstraint("tblAuctioneerFees", {
      fields: ["auctioneer_id"],
      type: "foreign key",
      name: "restrict_feeauctioneer_fkey", // optional: give a custom name
      references: {
        table: "tblAuctioneers",
        field: "auctioneer_id",
      },
      onDelete: "RESTRICT",
      onUpdate: "CASCADE",
    });

    await queryInterface.addConstraint("tblVehicleRunFees", {
      fields: ["auctioneer_fee_id"],
      type: "foreign key",
      name: "restrict_auctioneerfee_fkey", // optional: give a custom name
      references: {
        table: "tblAuctioneerFees",
        field: "auctioneer_fee_id",
      },
      onDelete: "RESTRICT",
      onUpdate: "CASCADE",
    });

    await queryInterface.addConstraint("tblAuctionLanes", {
      fields: ["auction_id"],
      type: "foreign key",
      name: "restrict_auction_fkey", // optional: give a custom name
      references: {
        table: "tblAuctions",
        field: "auction_id",
      },
      onDelete: "RESTRICT",
      onUpdate: "CASCADE",
    });

    await queryInterface.addConstraint("tblOpportunities", {
      fields: ["auctioneer_id"],
      type: "foreign key",
      name: "restrict_oppauctioneer_fkey", // optional: give a custom name
      references: {
        table: "tblAuctioneers",
        field: "auctioneer_id",
      },
      onDelete: "RESTRICT",
      onUpdate: "CASCADE",
    });

    await queryInterface.addConstraint("tblOpportunities", {
      fields: ["user_id"],
      type: "foreign key",
      name: "restrict_oppuser_fkey", // optional: give a custom name
      references: {
        table: "tblUsers",
        field: "user_id",
      },
      onDelete: "RESTRICT",
      onUpdate: "CASCADE",
    });

    await queryInterface.addConstraint("tblUserSubAuctioneers", {
      fields: ["user_id"],
      type: "foreign key",
      name: "restrict_subuser_fkey", // optional: give a custom name
      references: {
        table: "tblUsers",
        field: "user_id",
      },
      onDelete: "RESTRICT",
      onUpdate: "CASCADE",
    });

    await queryInterface.addConstraint("tblUserSubAuctioneers", {
      fields: ["auctioneer_id"],
      type: "foreign key",
      name: "restrict_subauctioneer_fkey", // optional: give a custom name
      references: {
        table: "tblAuctioneers",
        field: "auctioneer_id",
      },
      onDelete: "RESTRICT",
      onUpdate: "CASCADE",
    });

    await queryInterface.addConstraint("tblVehicleRunFees", {
      fields: ["vehicle_run_id"],
      type: "foreign key",
      name: "restrict_vehiclerunfee_fkey", // optional: give a custom name
      references: {
        table: "tblVehicleRuns",
        field: "vehicle_run_id",
      },
      onDelete: "RESTRICT",
      onUpdate: "CASCADE",
    });
  },

  async down(queryInterface, Sequelize) {
    await queryInterface.removeConstraint("tblVehicles", "restrict_user_fkey");

    await queryInterface.removeConstraint(
      "tblVehicleRuns",
      "restrict_vehicle_fkey"
    );

    await queryInterface.removeConstraint(
      "tblVehicleRuns",
      "restrict_lane_fkey"
    );

    await queryInterface.removeConstraint(
      "tblVehicleRuns",
      "restrict_opportunity_fkey"
    );

    await queryInterface.removeConstraint(
      "tblVehicleImages",
      "restrict_imgvehicle_fkey"
    );

    await queryInterface.removeConstraint(
      "tblAuctionLanes",
      "restrict_auctioneer_fkey"
    );
    await queryInterface.removeConstraint(
      "tblAuctioneerFees",
      "restrict_feeauctioneer_fkey"
    );

    await queryInterface.removeConstraint(
      "tblVehicleRunFees",
      "restrict_auctioneerfee_fkey"
    );

    await queryInterface.removeConstraint(
      "tblAuctionLanes",
      "restrict_auction_fkey"
    );

    await queryInterface.removeConstraint(
      "tblOpportunities",
      "restrict_oppauctioneer_fkey"
    );

    await queryInterface.removeConstraint(
      "tblOpportunities",
      "restrict_oppuser_fkey"
    );

    await queryInterface.removeConstraint(
      "tblUserSubAuctioneers",
      "restrict_subuser_fkey"
    );

    await queryInterface.removeConstraint(
      "tblUserSubAuctioneers",
      "restrict_subauctioneer_fkey"
    );

    await queryInterface.removeConstraint(
      "tblUserSubAuctioneers",
      "restrict_vehiclerunfee_fkey"
    );
  },
};

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists