Fix bug when creating database tables