Migrations for postgresql

Few fixes so that migration works better with postgresql.
Also foreign key constraints to product table prevented use of different product model.