Check table existence before define_counter_cache and update_counter_cache

```bash
rake db:migrate
```
fails because of table absence. *define_counter_cache* and *update_counter_cache* were flavoured with table existence check.