#!/bin/sh

#curl -X POST http://localhost:8083/connectors/jdbc-sink-to-postgres/restart

curl -X DELETE http://localhost:8083/connectors/jdbc-sink-to-postgres



curl -i -X POST http://localhost:8083/connectors/ \
  -H "Accept:application/json" \
  -H "Content-Type:application/json" \
  -d \
'{
    "name": "jdbc-sink-to-postgres",
    "config": {
        "connector.class": "io.debezium.connector.jdbc.JdbcSinkConnector",
        "connection.url": "jdbc:postgresql://5.160.139.99:4011/subtitle_system?currentSchema=target",
        "connection.username": "postgres",
        "connection.password": "OurPostGGresPPPasword",
        "insert.mode": "upsert",
        "auto.create": "true",
        "auto.evolve": "true",
        "schema.evolution": "basic",  
        "primary.key.fields": "id",
        "primary.key.mode": "record_key",
        "errors.max.retries": "-1",
        "retriable.restart.connector.wait.ms": "30000",
        "topics.regex": "(movie_titles|system_tokens|system_users|users_movie_subtitle_comments|users_movie_subtitles|users_movie_subtitles_rates|users_movie_subtitles_vtt|users_movie_subtitles_vtt_ads)",
        "quote.identifiers":"true",
        "value.converter.schemas.enable":"true",            
        "value.converter":"org.apache.kafka.connect.json.JsonConverter",
        "table.name.format": "${topic}"
    }
}'
