samedi 7 mai 2016

How do I add a new field to my sqlite3 data base?

I have a javascript file for my data base and I added 2 fields to it(email and password) and exported it to my db.js file like - (the following 2 lines are in my db.js file)

            var db={};
            db.user=sequelize.import(__dirname+'/models/user.js');

my user.js has -

    module.exports = function(sequelize, DataTypes) {
    return sequelize.define('user',{
    email:{
        type:DataTypes.STRING,
        allowNull:false,
        unique:true, //no two same emails
        validate:{
            isEmail:true
        }
    },
    password:{
        type:DataTypes.STRING,
        allowNull:false,
        validate:{
            len:[7,100]
        }
    }

});
      };

If I want to add another field to it say, "displayName", how do i do that? i tried adding

    displayname:{
        type:DataTypes.STRING,
        allowNull:false,
        validate:{
            len:[3,9]
        }
    }

like that after the password field, but when i check the table on sqlitebrowser, nothing gets updated. So how do I do this?

Aucun commentaire:

Enregistrer un commentaire