Permalink
Browse files

created Wine and Beer models in ladybird_db

  • Loading branch information...
brianogilvie committed Feb 10, 2019
1 parent ad7818a commit 4ff8ab61c9889f9d3a1df1e8013f35e674b27c26
Showing with 61 additions and 2 deletions.
  1. +20 −1 models/index.js
  2. +1 −1 scripts/resetDb.js
  3. +40 −0 scripts/seed.js
@@ -23,16 +23,35 @@ const Cocktail = db.define('cocktail', {
const Wine = db.define('wine', {
category: {
type: Sequelize.ENUM,
values: ['white', 'rose', 'red']
values: ['white', 'rose', 'red', 'bubbles', 'dessert wine']
},
varietal: Sequelize.STRING,
vineyard: Sequelize.STRING,
region: Sequelize.STRING,
year: {
type: Sequelize.INTEGER,
len: [4,4],
},
glass_price: Sequelize.INTEGER,
bottle_price: Sequelize.INTEGER,
comment: Sequelize.STRING,
})

const Beer = db.define('beer', {
category: {
type: Sequelize.STRING,
allowNull: false,
},
name: {
type: Sequelize.STRING,
allowNull: false,
},
brewery: Sequelize.STRING,
region: Sequelize.STRING,
container: Sequelize.STRING,
oz: Sequelize.INTEGER,
abv: Sequelize.REAL,
price: Sequelize.INTEGER,
})

const Food = db.define('food', {
@@ -3,7 +3,7 @@ const {db} = require('../models')
const reset = async () => {
try {
await db.sync({force: true})
console.log('🗄 ', 'database reset')
console.log('🗄 ', 'database successfully reset')
} catch (e) {
console.log('‼️ ', e.message)
}
@@ -0,0 +1,40 @@
const {Wine, Cocktail, Food} = require('../models')

const seed = async () => {
try {
await Wine.truncate({restartIdentity: true})
await Wine.bulkCreate([
{category: 'white', varietal: 'riesling', vineyard: 'selbach-oster', region: 'mosel, germany', year: 2014, glass_price: 13, bottle_price: 50},
{category: 'white', varietal: 'HONDARRABI ZURI', vineyard: 'ameztol \'txabolia\'', region: 'pais vasco, spain', year: 2017, glass_price: 13, bottle_price: 50},
{category: 'white', varietal: 'SAUVIGNON BLANC', vineyard: 'supernatural', region: 'hawke\'s bay, new zealand', year: 2014, glass_price: 15, bottle_price: 48},
{category: 'white', varietal: 'FIANO', vineyard: 'casetllo manaci', region: 'puglia, italy', year: 2015, glass_price: 14, bottle_price: 54},
{category: 'white', varietal: 'CHARDONNAY', vineyard: 'walt vineyards', region: 'sonoma coast, ca', year: 2014, glass_price: 16, bottle_price: 64},
{category: 'white', varietal: 'CHENIN BLANC', vineyard: 'kunin \'jurassic park\'', region: 'sonoma coast, ca', year: 2015, glass_price: null, bottle_price: 72},
{category: 'white', varietal: 'RIESLING', vineyard: 'cobb \'vonarburg vineyard\'', region: 'anderson valley, ca', year: 2016, glass_price: null, bottle_price: 80},
{category: 'white', varietal: 'CARRICANTE', vineyard: 'graci \'etna blanco arcuria\'', region: 'etna, sicily', year: 2015, glass_price: null, bottle_price: 95},
{category: 'rose', varietal: 'GETARIA ROSE', vineyard: 'domaine des cassagnoles', region: 'gascogne, france', year: 2016, glass_price: 12, bottle_price: 46},
{category: 'rose', varietal: 'ETNA ROSATO', vineyard: 'graci', region: 'etna, sicily', year: 2017, glass_price: 13, bottle_price: 50},
{category: 'rose', varietal: 'BEKAA VALLEY JEUNE', vineyard: 'chateau musar', region: 'bekaa valley, lebanon', year: 2016, glass_price: 14, bottle_price: 54},
{category: 'rose', varietal: 'ROSE ON TAP', glass_price: 10, bottle_price: 25, comment: 'ask your server for today\'s select rose! bottles are 500ml (3 glasses)'},
{category: 'red', varietal: 'PINOT NOIR', vineyard: 'copain \'tous ensemble\'', region: 'sonoma coast, ca', year: 2016, glass_price: 16, bottle_price: 62},
{category: 'red', varietal: 'GRENACHE', vineyard: 'tim smith \'bugalugs\'', region: 'barossa valley, australia ', year: 2017, glass_price: 12, bottle_price: 46},
{category: 'red', varietal: 'TREPAT', vineyard: 'moli dels capellans \'la coma\'', region: 'catalonia, spain', year: 2016, glass_price: 14, bottle_price: 55},
{category: 'red', varietal: 'RHONE BLEND', vineyard: 'fausse piste \'mourvedre, syrah, grenache\'', region: 'columbia valley, wa', year: 2016, glass_price: 13, bottle_price: 58},
{category: 'red', varietal: 'MALBEC', vineyard: 'cosse et maisonneuve \'le combal\'', region: 'cahors, france', year: 2014, glass_price: 15, bottle_price: 58},
{category: 'red', varietal: 'SYRAH', vineyard: 'la clarine farm \'sierra foothills\'', region: 'el dorado county, ca', year: null, glass_price: null, bottle_price: 64},
{category: 'red', varietal: 'CABERNET FRANC', vineyard: 'leah jorgensen cellars \'tour rain\'', region: 'walla walla valley, wa', year: 2016, glass_price: null, bottle_price: 78},
{category: 'red', varietal: 'PINOT NOIR', vineyard: 'timbre \'lead vocals; bien nacido\'', region: 'santa maria valley, ca', year: 2015, glass_price: null, bottle_price: 92},
{category: 'bubbles', varietal: 'PROSECCO', vineyard: 'case paolin', region: 'asolo prosecco, italy', year: null, glass_price: 14, bottle_price: 54},
{category: 'bubbles', varietal: 'CAVA ROSE', vineyard: 'dibon', region: 'cava, spain', year: null, glass_price: 12, bottle_price: 42},
{category: 'bubbles', varietal: 'BLANC DE BLANC', vineyard: 'raventos', region: 'catalonia, spain', year: 2014, glass_price: 13, bottle_price: 52},
{category: 'dessert wine', varietal: 'HARSLEVELU', vineyard: 'chateau pajzos \'takaji late harvest h\'', region: 'tokai, hungary', year: 2014, glass_price: 14, bottle_price: 28},
{category: 'dessert wine', varietal: 'MOSCATO', vineyard: 'la spinetta \'d\' asti biancospino\'', region: 'piedmont, italy', year: 2017, glass_price: null, bottle_price: 22, comment: '*half bottle'},
])

console.log('🗂 ', 'seed complete')
} catch (e) {
console.log('‼️ ', e.message)
}
}

seed()

0 comments on commit 4ff8ab6

Please sign in to comment.