I'm running into an error where when I do a get request in node to my database, I'm getting an empty array. So I look in the console log and it says it's dropping all tables if exist and then creating them but the seed file is not running. I can run "npm run seed" outside of the server and it will seed the database but it keeps dropping and not seeding when I run node server.js. I even tried putting the path to the seed inside the packages.json "start": to make both the seed and server run on start but no luck. The app was working perfectly but one of my team members accidentally pushed to the master and it messed up the app I don't know what's messed up because this was working before the git messup. I've created a new repo though now and getting same problem.
//package.json
"start": "node server.js ./seeds/seed-db.js"
//seed-db.js
const db = require("../models");
const productSeeds = require("./seed-products.json");
db.sequelize.sync({ force: true }).then(function() {
db.Market.bulkCreate([
{
name: "Cotton Mill Farmers Market",
address: "401 Rome St.",
city: "Carrollton",
state: "GA",
zip: "30117"
}
]).then(function(dbMarkets) {
//COTTON MILL FARMERS MARKET STOCK
dbMarkets[0].createProduct(productSeeds.broccoli).then(function() {
db.sequelize.close();
});
dbMarkets[1].createProduct(productSeeds.broccoli).then(function()
{
db.sequelize.close();
});
});
});
//console
Executing (default): DROP TABLE IF EXISTS MarketProduct;
Executing (default): DROP TABLE IF EXISTS Product;
Executing (default): DROP TABLE IF EXISTS Markets;
Executing (default): DROP TABLE IF EXISTS Markets;
Executing (default): CREATE TABLE IF NOT EXISTS Markets (id INTEGER NOT NULL auto_increment , name VARCHAR(255), address VARCHAR(255), city VARCHAR(255), state VARCHAR(255), zip INTEGER, PRIMARY KEY (id)) ENGINE=InnoDB;
Executing (default): SHOW INDEX FROM Markets FROM grocerEZ_db
Executing (default): DROP TABLE IF EXISTS Product;
Executing (default): CREATE TABLE IF NOT EXISTS Product (id INTEGER NOT NULL auto_increment , name VARCHAR(255), category ENUM('meat', 'fruits', 'vegetables', 'misc'), isOrganic TINYINT(1), PRIMARY KEY (id)) ENGINE=InnoDB;
Executing (default): SHOW INDEX FROM Product FROM grocerEZ_db
Executing (default): DROP TABLE IF EXISTS MarketProduct;
Executing (default): CREATE TABLE IF NOT EXISTS MarketProduct (createdAt DATETIME NOT NULL, updatedAtDATETIME NOT NULL, MarketId INTEGER , ProductId INTEGER , PRIMARY KEY (MarketId, ProductId), FOREIGN KEY (MarketId) REFERENCES Markets (id) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (ProductId) REFERENCES Product (id) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB;
Executing (default): SHOW INDEX FROM MarketProduct FROM grocerEZ_db
App listening on PORT 3000