Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

BulkInsert "relation does not exist" in migration script

Open
#1,377 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
javascript
Domain
cli, databases

Research direction

Start by reproducing the migration script and inspect the queryInterface.createTable and bulkInsert calls, including their shared transaction and schema options. Done means the migration creates lookup__google_places_types and inserts the provided rows without the relation error; the payload names no repository files or tests to begin with.

Written by the indexing model from the issue text.

Description

type: bug

Issue Creation Checklist

  • I understand that my issue will be automatically closed if I don't fill in the requested information
  • I have read the contribution guidelines

Bug Description

I have created a migration script that creates a table and then bulk inserts a bunch of values. The CreateTable statement works no problem but when it comes to inserting the data it keeps telling me that the relation does not exist and I have tried everything to try and get around that to no avail.

Reproducible Example
// sequelize script migration to create the lookup-google-places-types table
module.exports = {
  up: async (queryInterface, Sequelize) => {
    await queryInterface.sequelize.transaction(async (t) => {
      await queryInterface.createTable(
        'lookup__google_places_types',
        {
          place_type: {
            type: Sequelize.STRING,
            primaryKey: true,
          },
          report_type: {
            type: Sequelize.STRING,
            allowNull: false,
          },
          google_reviews: {
            type: Sequelize.BOOLEAN,
            defaultValue: false,
          },
          contacts: {
            type: Sequelize.BOOLEAN,
            defaultValue: false,
          },
          social_links: {
            type: Sequelize.BOOLEAN,
            defaultValue: false,
          },
          competitors_map: {
            type: Sequelize.BOOLEAN,
            defaultValue: false,
          },
          created_at: {
            allowNull: false,
            type: Sequelize.DATE,
            defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'),
          },
          updated_at: {
            allowNull: false,
            type: Sequelize.DATE,
            defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'),
          },
          deleted_at: {
            type: Sequelize.DATE,
          },
        },
        {
          schema: 'backend',
          transaction: t,
        }
      );

      // Insert statements for lookup__google_places_types to fill in place_type and report_type with a series of tuples
      // example being ('accounting', 'full') or ('airport', 'plus')
      await queryInterface.bulkInsert(
        {
          tableName: 'lookup__google_places_types',
          schema: 'backend',
          transaction: t,
        },
        [
          {
            place_type: 'accounting',
            report_type: 'full',
          },
          {
            place_type: 'airport',
            report_type: 'plus',
          },
          {
            place_type: 'amusement_park',
            report_type: 'full',
          },
          {
            place_type: 'aquarium',
            report_type: 'full',
          },
          {
            place_type: 'art_gallery',
            report_type: 'full',
          },
          {
            place_type: 'atm',
            report_type: 'plus',
          },
          {
            place_type: 'bakery',
            report_type: 'full',
          },
          {
            place_type: 'bank',
            report_type: 'full',
          },
          {
            place_type: 'bar',
            report_type: 'full',
          },
          {
            place_type: 'beauty_salon',
            report_type: 'full',
          },
          {
            place_type: 'bicycle_store',
            report_type: 'full',
          },
          {
            place_type: 'book_store',
            report_type: 'full',
          },
          {
            place_type: 'bowling_alley',
            report_type: 'full',
          },
          {
            place_type: 'bus_station',
            report_type: 'plus',
          },
          {
            place_type: 'cafe',
            report_type: 'full',
          },
          {
            place_type: 'campground',
            report_type: 'full',
          },
          {
            place_type: 'car_dealer',
            report_type: 'full',
          },
          {
            place_type: 'car_rental',
            report_type: 'full',
          },
          {
            place_type: 'car_repair',
            report_type: 'full',
          },
          {
            place_type: 'car_wash',
            report_type: 'full',
          },
          {
            place_type: 'casino',
            report_type: 'full',
          },
          {
            place_type: 'cemetery',
            report_type: 'full',
          },
          {
            place_type: 'church',
            report_type: 'thin',
          },
          {
            place_type: 'city_hall',
            report_type: 'thin',
          },
          {
            place_type: 'clothing_store',
            report_type: 'full',
          },
          {
            place_type: 'convenience_store',
            report_type: 'full',
          },
          {
            place_type: 'courthouse',
            report_type: 'thin',
          },
          {
            place_type: 'dentist',
            report_type: 'full',
          },
          {
            place_type: 'department_store',
            report_type: 'full',
          },
          {
            place_type: 'doctor',
            report_type: 'full',
          },
          {
            place_type: 'drugstore',
            report_type: 'full',
          },
          {
            place_type: 'electrician',
            report_type: 'full',
          },
          {
            place_type: 'electronics_store',
            report_type: 'full',
          },
          {
            place_type: 'embassy',
            report_type: 'thin',
          },
          {
            place_type: 'fire_station',
            report_type: 'thin',
          },
          {
            place_type: 'florist',
            report_type: 'full',
          },
          {
            place_type: 'funeral_home',
            report_type: 'full',
          },
          {
            place_type: 'furniture_store',
            report_type: 'full',
          },
          {
            place_type: 'gas_station',
            report_type: 'full',
          },
          {
            place_type: 'gym',
            report_type: 'full',
          },
          {
            place_type: 'hair_care',
            report_type: 'full',
          },
          {
            place_type: 'hardware_store',
            report_type: 'full',
          },
          {
            place_type: 'hindu_temple',
            report_type: 'thin',
          },
          {
            place_type: 'home_goods_store',
            report_type: 'full',
          },
          {
            place_type: 'hospital',
            report_type: 'full',
          },
          {
            place_type: 'insurance_agency',
            report_type: 'full',
          },
          {
            place_type: 'jewelry_store',
            report_type: 'full',
          },
          {
            place_type: 'laundry',
            report_type: 'full',
          },
          {
            place_type: 'lawyer',
            report_type: 'full',
          },
          {
            place_type: 'library',
            report_type: 'plus',
          },
          {
            place_type: 'light_rail_station',
            report_type: 'plus',
          },
          {
            place_type: 'liquor_store',
            report_type: 'full',
          },
          {
            place_type: 'local_government_office',
            report_type: 'thin',
          },
          {
            place_type: 'locksmith',
            report_type: 'full',
          },
          {
            place_type: 'lodging',
            report_type: 'full',
          },
          {
            place_type: 'meal_delivery',
            report_type: 'full',
          },
          {
            place_type: 'meal_takeaway',
            report_type: 'full',
          },
          {
            place_type: 'mosque',
            report_type: 'thin',
          },
          {
            place_type: 'movie_rental',
            report_type: 'full',
          },
          {
            place_type: 'movie_theater',
            report_type: 'full',
          },
          {
            place_type: 'moving_company',
            report_type: 'full',
          },
          {
            place_type: 'museum',
            report_type: 'full',
          },
          {
            place_type: 'night_club',
            report_type: 'full',
          },
          {
            place_type: 'painter',
            report_type: 'full',
          },
          {
            place_type: 'park',
            report_type: 'plus',
          },
          {
            place_type: 'parking',
            report_type: 'full',
          },
          {
            place_type: 'pet_store',
            report_type: 'full',
          },
          {
            place_type: 'pharmacy',
            report_type: 'full',
          },
          {
            place_type: 'physiotherapist',
            report_type: 'full',
          },
          {
            place_type: 'plumber',
            report_type: 'full',
          },
          {
            place_type: 'police',
            report_type: 'thin',
          },
          {
            place_type: 'post_office',
            report_type: 'plus',
          },
          {
            place_type: 'primary_school',
            report_type: 'plus',
          },
          {
            place_type: 'real_estate_agency',
            report_type: 'full',
          },
          {
            place_type: 'restaurant',
            report_type: 'full',
          },
          {
            place_type: 'roofing_contractor',
            report_type: 'full',
          },
          {
            place_type: 'rv_park',
            report_type: 'full',
          },
          {
            place_type: 'school',
            report_type: 'plus',
          },
          {
            place_type: 'secondary_school',
            report_type: 'plus',
          },
          {
            place_type: 'shoe_store',
            report_type: 'full',
          },
          {
            place_type: 'shopping_mall',
            report_type: 'full',
          },
          {
            place_type: 'spa',
            report_type: 'full',
          },
          {
            place_type: 'stadium',
            report_type: 'plus',
          },
          {
            place_type: 'storage',
            report_type: 'full',
          },
          {
            place_type: 'store',
            report_type: 'full',
          },
          {
            place_type: 'subway_station',
            report_type: 'plus',
          },
          {
            place_type: 'supermarket',
            report_type: 'full',
          },
          {
            place_type: 'synagogue',
            report_type: 'thin',
          },
          {
            place_type: 'taxi_stand',
            report_type: 'full',
          },
          {
            place_type: 'tourist_attraction',
            report_type: 'full',
          },
          {
            place_type: 'train_station',
            report_type: 'plus',
          },
          {
            place_type: 'transit_station',
            report_type: 'plus',
          },
          {
            place_type: 'travel_agency',
            report_type: 'full',
          },
          {
            place_type: 'university',
            report_type: 'full',
          },
          {
            place_type: 'veterinary_care',
            report_type: 'full',
          },
          {
            place_type: 'zoo',
            report_type: 'full',
          },
        ],
        {}
      );
    });
  },
  down: async (queryInterface, Sequelize) => {
    await queryInterface.dropTable('lookup__google_places_types');
  },
};
What do you expect to happen?

Table should be created and the records inserted!

What is actually happening?

image

Environment
  • Sequelize version: sequelize@6.32.1
  • Node.js version: v18.12.1
  • If TypeScript related: TypeScript version:
  • Database & Version: AWS Aurora Postgres
  • Connector library & Version: pg

Would you be willing to resolve this issue by submitting a Pull Request?

  • Yes, I have the time and I know how to start.
  • Yes, I have the time but I will need guidance.
  • No, I don't have the time, but my company or I are supporting Sequelize through donations on OpenCollective.
  • No, I don't have the time, and I understand that I will need to wait until someone from the community or maintainers is interested in resolving my issue.

Indicate your interest in the resolution of this issue by adding the 👍 reaction. Comments such as "+1" will be removed.

Dominant language
JavaScript
Stars
2.6k
Forks
524
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sequelize/cli

All issues in sequelize/cli

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.