Fixed database connection problem and tables migration order