It's super simple to crank up a little service that persists to timescaledb in spring data. But while spring data will connect and create your schema from your model, it obviously doesn't create the hypertables that wrap your tables. What is the standard way to create your hypertables with a spring boot service using spring data?
Would something like this work?
@Slf4j
@Repository
@DependsOn({"readingRepository"})
public class CustomTimescaleRepository {
@PersistenceContext
EntityManager entityManager;
@PostConstruct
@Transactional
@Modifying
void createHypertables() {
log.info("CREATING HYPERTABLES");
Query query = entityManager.createNativeQuery("SELECT create_hypertable('reading','timestamp')");
query.getFirstResult();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With