docker-compose up
docker exec -it scylla-node1 nodetool status
docker exec -it scylla-node1 cqlsh
DROP KEYSPACE rinha_db;
CREATE KEYSPACE rinha_db
WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 3};
USE rinha_db;
CREATE TABLE IF NOT EXISTS conta_lock (
id INT,
time TIMESTAMP,
primary key (id)
) WITH default_time_to_live = 6000;
CREATE TABLE IF NOT EXISTS conta (
id INT,
limite INT,
saldo_inicial INT,
version INT,
primary key (id)
);
CREATE TABLE IF NOT EXISTS transaction_history (
id UUID,
account_id INT,
amount INT,
type TEXT,
description TEXT,
created_at TIMESTAMP,
primary key ((account_id), id, created_at)
) WITH CLUSTERING ORDER BY (id DESC, created_at DESC);
INSERT INTO conta (id, limite, saldo_inicial, version) VALUES (1, 100000, 0, 1);
INSERT INTO conta (id, limite, saldo_inicial, version) VALUES (2, 80000, 0, 1);
INSERT INTO conta (id, limite, saldo_inicial, version) VALUES (3, 1000000, 0, 1);
INSERT INTO conta (id, limite, saldo_inicial, version) VALUES (4, 10000000, 0, 1);
INSERT INTO conta (id, limite, saldo_inicial, version) VALUES (5, 500000, 0, 1);
INSERT INTO conta_lock (id, time) VALUES (1, toTimestamp(now())) IF NOT EXISTS;
SELECT * FROM conta where id = 1;
SELECT * FROM conta;