'use strict';

module.exports = {
    up: (queryInterface, Sequelize) => {
        return queryInterface.createTable('Orders', {
            id: {
                allowNull: false,
                autoIncrement: true,
                primaryKey: true,
                type: Sequelize.INTEGER
            },
            goodsId: {
                allowNull: false,
                type: Sequelize.INTEGER,
                onDelete: "CASCADE",
                references: {
                    model: "GoodsAttributes",
                    key: 'id'
                }
            },
            packageId: {
              allowNull: false,
              type: Sequelize.STRING
            },
            userId: {
              allowNull: true,
              type: Sequelize.INTEGER,
              defaultValue: null
            },
            count: {
                allowNull: false,
                type: Sequelize.INTEGER
            },
            name: {
              allowNull: false,
              type: Sequelize.STRING
            },
            surname: {
                allowNull: false,
                type: Sequelize.STRING
            },
            phone: {
              allowNull: false,
              type: Sequelize.STRING
            },
            city: {
                allowNull: false,
                type: Sequelize.STRING
            },
            home: {
                allowNull: false,
                type: Sequelize.STRING
            },
            street: {
                allowNull: false,
                type: Sequelize.STRING
            },
            apartment: {
                allowNull: true,
                type: Sequelize.STRING
            },
            orderStatus: {
              allowNull: false,
              type: Sequelize.STRING,
              defaultValue: '1_not_confirmed'
            },
            createdAt: {
                allowNull: false,
                type: Sequelize.DATE,
                defaultValue: Sequelize.NOW
            },
            updatedAt: {
                allowNull: false,
                type: Sequelize.DATE
            }
        });
    },
    down: (queryInterface, Sequelize) => {
        return queryInterface.dropTable('Orders');
    }
};
