The use of DataTypes.DECIMAL in Sequelize auto-migration command might be resulting in an error stating 'Unknown column'

I am currently working with Sequelize, an ORM for Node.js, and I am facing an issue when trying to add a column to a table with a data type of 'DECIMAL'. Despite successfully adding columns with other data types like DATE and STRING to similar tables, the changeColumn function is not executing properly in this case. Instead, I receive an error stating 'ERROR: Unknown column 'default_price' in 'category' when I attempt to run the command sequelize db:migrate. As a beginner in development, I am still learning and haven't gained much experience with Sequelize yet.

Upon running the command:
L05HandsOn>sequelize db:migrate
I encountered some deprecation warnings and an error related to the 'default_price' column during the migration process. Here is a snippet of the output:

[#0] execute: changeColumn
ERROR: Unknown column 'default_price' in 'category

Within my migration.js file, the specific command causing the issue is defined as follows:

fn: "changeColumn",
params: [
    "category",
    "default_price",
    {
        "type": Sequelize.DECIMAL(2, 2),
        "field": "default_price",
        "allowNull": false
    }
]

The expected output upon successfully running 'sequelize db:migrate' is:

[#0] execute: changeColumn
2-category_Decimal_migration: migrated (0.XXXs)

Answer №1

The solution to this problem involved running an addColumn command before changeColumn. I mistakenly tried to change a column that did not exist. When using auto-Sequelize commands, it is crucial to follow the file creation steps in the correct order. Although Sequelize does not explicitly notify you of the sequence error, it may generate new migration files. This could lead to confusion as a migration might not be successfully executed if the model creation steps are not carried out in the correct order.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Error in THREE.js: Unable to access property 'lib' from an undefined source (THREE.ShaderUtils.lib["normal"])

I have been working on the challenges provided in the WebGL introductory book by Oreilly. Encountered a runtime error with the following code snippet. After searching online, it seems like I am the only one facing this issue. Could you please assist me in ...

How do you trigger a function in a child component that was imported when a parent element is clicked?

Is it possible to access and call a function in an imported component from the "parent element"? I have multiple modules that I want to include dynamically in my app. I thought that if I import a component like Header in my main App.vue file, it would reco ...

Is there an issue with the MySQL partitioning by range query?

Having some trouble altering an existing table with partitioning, despite following the documentation closely. Any assistance in identifying my mistake would be greatly appreciated. The table "orders" includes a field called date_order_start, which is a ...

Angular Flot Chart Resizing: A Guide to Dynamic Chart S

I have successfully integrated a Flot chart into my HTML using an Angular directive. Here is how it looks: <flot id="placeholder" dataset="dataset" options="options" height="300px" width="100%" style="width:100%;" ng-disabled="graphLoading" ng-class="{ ...

Converting Cookies to Numeric Values in JavaScript: A Step-by-Step Guide

I'm currently developing a cookie clicker website and am encountering an issue with saving the user's score to localstorage when they click the "save" button. Here is what my code looks like: let score = 0; function addPoint() { score += 1; } ...

The function element.checked = true/false in Vanilla Javascript seems to be malfunctioning

Here is the HTML code I am working with: <ul class="nav md-pills pills-default flex-column" role="tablist"> <li class="nav-item"> <input type="radio" name="q01" value="1" hidden checked> <a class="nav-link choice01 ...

What is the best way to dynamically insert a directive element between an already existing parent directive and its child directive?

Background: Working within the constraints of a custom CMS that limits access to the code base, I am exploring the option of using JavaScript for DOM manipulations in certain scenarios. Problem: The issue I am facing involves a container directive conta ...

Is the Vuex mutation properly formatted?

Is the mutation method correctly written to modify the initial state array? I'm uncertain about the last few lines of the mutation method. What am I missing, if anything? // Storing state: { flights: [ {trip_class: 0, number_of_change="1"}, ...

Helping React and MUI components become mobile responsive - Seeking guidance to make it happen

My React component uses Material-UI (MUI) and I'm working on making it mobile responsive. Here's how it looks currently: https://i.sstatic.net/kxsSD.png But this is the look I want to achieve: https://i.sstatic.net/kJC2m.png Below is the code ...

Explore the contents of JSON, PHP, and Android through reading their respective paragraphs

I recently started developing an Android app and I'm facing an issue with multiple paragraphs in my MySQL database. Currently, my data is stored in MySQL on a web server, and I'm using a PHP script to read the data from MySQL, convert it to JSON, ...

Issue with AJAX POST request, values not being passed to variables despite being displayed in the echo output

I am facing an issue with my Ajax post request, where the server seems to be receiving two date variables as empty even though they are sending correctly based on what I can see in the echo statement. The gettype function is returning NULL when trying to c ...

Dealing with Sideways Overflow Using slideDown() and slideUp()

Attempting to use slideUp() and slideDown() for an animated reveal of page elements, I encountered difficulty when dealing with a relatively positioned icon placed outside the element. During these animations, overflow is set to hidden, resulting in my ico ...

Simple Way to Modify Color of Active Page Link - HTML, CSS, and JavaScript

I found a helpful example on how to change link colors for the current page here. Here is the script I added: <script> // current page highlight $(document).ready(function() { $("[href]").each(function() { if (this.href == window.l ...

What is the process for ordering by a many-to-many relationship in Sequelize?

I am dealing with a many-to-many relationship between User and Category, connected through the UserCategory model. Here is the code snippet illustrating this relationship: let user = await User.findAll({ where: { id: req.query.user }, attribut ...

Exploring Laravel 5.5: Harnessing the Power of Join and Where Clauses in Query Building

My Dilemma Involves Two Tables 'Orders' with Columns ['subtotal', 'taxes', 'delivery_fee', 'total', 'discount', 'status', 'delivery_status','payment_status', &apos ...

Entry duplication in the table

Health Risk Data Column 1 - Primary Key - Name Column 2 - Description Health Risk Components Table Column 1 - Auto Increment/Primary Key - ID Column 2 - Ingredient Name Column 3 - Foreign Key - column1.name For instance, let's add a row to t ...

Deciding the optimal time to start a new JavaScript file and effectively organizing source code

Embarking on a substantial map application project involving approximately 5,000 lines of JavaScript, I am contemplating changing my approach to file organization. Traditionally, I would consolidate all code into a single file named 'main.js', bu ...

Is there a way to link the scrolling of two ag-grid data tables together for synchronized movement?

I have integrated ag-grid into my Angular project and I am looking to display two data tables (ag-grid) stacked on top of each other. Both data tables should scroll together, meaning when I scroll in table 1 or table 2, the content of both tables should m ...

Encountering a Laravel issue within my application. Each question is followed by a subsequent question based on the provided answer. All questions and corresponding answers are stored in the database

I am brand new to Laravel and databases as I work on creating a web application for individuals facing difficulties with specific products. The app prompts users with questions and based on their answers, directs them to the next question in sequence. Each ...

The mysqli class encountered an error due to a failure in retrieving network addresses: php_network_getaddresses reported that the process of obtaining address

<?php function establishDatabaseConnection($host, $user, $pass, $database) { global $mysqli; global $Mysqlerror; $mysqli = new mysqli('$host', '$user', '$pass', '$database'); if (empty($mysqli-> ...