The main idea for this repository is shamelessly stolen from http://mean.io. It says:
MEAN is a boilerplate that provides a nice starting point for [MySQL], Express, Node.js, and AngularJS based applications. It is designed to give you quick and organized way to start developing of MEAN based web apps with useful modules like sequelize and passport pre-bundled and configured. We mainly try to take care of the connection points between existing popular frameworks and solve common integration problems.
The MongoDB ORM, Mongoose, has been replaced with Sequelize. Switching from mongoose to sequelize allows developers easy access to MySQL, MariaDB, SQLite or PostgreSQL databases by mapping database entries to objects and vice versa.
Addy Osmani's Blog explains SQL databases, being strongly typed in nature are great at enforcing a level of consistency, ensuring many kinds of bad data simply don’t get recorded. By using SQL databases MEAN Stack Relational favors reliability over the performance gains of NoSQL databases.
Alright now the fun begins. First clone or download the repo to your computer.
git clone git@github.com:jpotts18/mean-stack-relational.git
.cd mean-stack-relational/
.npm install
./config/env/development.js
./config/env/development.js
.grunt
.Thats all! Now go and open up your browser at http://localhost:3000, and tweet @jpotts18 to say thanks!
NPM - Node.js package manager, should be installed when you install node.js. NPM (Node Package Manager) will look at the package.json file in the root of the project and download all of the necessary dependencies and put them in a folder called node_modules
Bower - Web package manager, installing Bower is simple when you have npm:
npm install -g bower
Grunt install grunt with "bower install"
Convert RentedSchema_v2.sql (MySQL) schema and apply it to postgresql DB using DBConvert for MySQL & PostgreSQL trial or one of the other methods listed in Converting from other Databases to PostgreSQL. Make sure that column names are camelCase, like they were in mySQL.
NOTE: when converting to PostgreSQL it might be necessarry to shorten some index names due to PostreSql index name length limitation. In our case i did following changes:
apartment_complex_floor_plan_PRIMARY_apartment_complex_floor_plan apartment_complex_transportation_PRIMARY_apartment_complex_transportation apartment_complex_transportation_PRIMARY_apartment_complex_transportation
renamed to:
apartment_complex_floor_plan_PRIMARY apartment_complex_transportation_PRIMARY apartment_complex_transportation_PRIMARY
Once we have schema applied to PG, Use sequelize-pg-generator to connect to PG database and generate javascript models (use config file and make sure to set useSchemaName to false while generating models). All models will be generated correctly.
CLI command: spgen -c
Note: it's possible that some models will have to be extended manually. So far it's just rentedUser model which was manually added instance methods, save hooks etc (for salt, crypting etc..)
Note: when instatiating Sequelize, sequelize-pg-generator uses ‘postgre’ as default sql dialect.. If other DB is used instead of PG (i.e. MySQL) it have to be stated when instatiating Sequelize.
Use RazorSQL to convert MySql Rented database schema ( all tables ) into Postgres schema ... note that I haven't found a way to do this with views yet Create a Postgres database Rented ( delete your old one first if applicable ) run the RentedSchemaPG_v.sql in sql window connected to Postgres Rented cd Rented/server directory spgen -d Rented -u -s Rented -o models Note: when instatiating Sequelize, sequelize-pg-generator uses ‘postgre’ as default sql dialect.. If other DB is used instead of PG (i.e. MySQL) it have to be stated when instatiating Sequelize.
psql -d Rented -f RentedSchemaPG_v5.sql
=======
Requires:
=======
======= Any ENUM model needs to have the double quotes removed Generated by the model script: type: Seq.ENUM('"no preference"', '"male only"', '"female only"') Required: type: Seq.ENUM('no preference', 'male only', 'female only')
===== To Deploy site:
==== Installing Amazon AWS CLI
export JAVA_HOME=/usr/libexec/java_home -v 1.7.0_75
export EC2_HOME=/usr/local/ec2/ec2-api-tools-1.7.3.0
export PATH=$PATH:$EC2_HOME/bin
export AWS_ACCESS_KEY=
====
Process for creating a new database:
Required to be done separately
=====
Process for restarting server after server changes
ps ax | grep node
find all node proccess running
sudo kill
NODE_PATH=/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript export NODE_PATH
NODE_ENV=production export NODE_ENV
sudo netstat -lnptu
====AWS IP Ranges===
https://ip-ranges.amazonaws.com/ip-ranges.json
====SSH into Live DB === psql --host rentedpg.cyngrnmslnob.us-west-2.rds.amazonaws.com --port 5432 --username ivan --dbname rented