Schema dump

I had issues with the order of tables being dumped with foreign key constrains.
I've moved the foreign key constrains at the bottom now and it seems to work well.