Coder Social home page Coder Social logo

Comments (8)

tulir avatar tulir commented on June 30, 2024

Are you using some weird postgres-ish server like cockroachdb?

from whatsmeow.

devalexandre avatar devalexandre commented on June 30, 2024

Are you using some weird postgres-ish server like cockroachdb?

I'm using cockroachdb serverless, but in the local postgres it gives the same error

from whatsmeow.

tulir avatar tulir commented on June 30, 2024

It works fine on real postgres, cockroach won't work right now because schema migrations aren't synchronous there.

from whatsmeow.

fnxln avatar fnxln commented on June 30, 2024

having same problem on real postgres 15.4

from whatsmeow.

Mauricio-Carrion avatar Mauricio-Carrion commented on June 30, 2024

Same trying to use cockroachdb here

from whatsmeow.

Mauricio-Carrion avatar Mauricio-Carrion commented on June 30, 2024

The error just ocurrs on upgrading database to v2 migration.

image

from whatsmeow.

Mauricio-Carrion avatar Mauricio-Carrion commented on June 30, 2024

In cockroachdb panel seems everthing right

image

from whatsmeow.

Mauricio-Carrion avatar Mauricio-Carrion commented on June 30, 2024

Now I extract the SQL statatements using ChatGPT from store/sqlstore/upgrade.go

CREATE TABLE IF NOT EXISTS whatsmeow_version (version INTEGER);

SELECT version FROM whatsmeow_version LIMIT 1;

DELETE FROM whatsmeow_version;

INSERT INTO whatsmeow_version (version) VALUES ($1);

CREATE TABLE whatsmeow_device (
    jid TEXT PRIMARY KEY,
    registration_id BIGINT NOT NULL CHECK (registration_id >= 0 AND registration_id < 4294967296),
    noise_key bytea NOT NULL CHECK (length(noise_key) = 32),
    identity_key bytea NOT NULL CHECK (length(identity_key) = 32),
    signed_pre_key bytea NOT NULL CHECK (length(signed_pre_key) = 32),
    signed_pre_key_id INTEGER NOT NULL CHECK (signed_pre_key_id >= 0 AND signed_pre_key_id < 16777216),
    signed_pre_key_sig bytea NOT NULL CHECK (length(signed_pre_key_sig) = 64),
    adv_key bytea NOT NULL,
    adv_details bytea NOT NULL,
    adv_account_sig bytea NOT NULL CHECK (length(adv_account_sig) = 64),
    adv_device_sig bytea NOT NULL CHECK (length(adv_device_sig) = 64),
    platform TEXT NOT NULL DEFAULT '',
    business_name TEXT NOT NULL DEFAULT '',
    push_name TEXT NOT NULL DEFAULT ''
);

CREATE TABLE whatsmeow_identity_keys (
    our_jid TEXT,
    their_id TEXT,
    identity bytea NOT NULL CHECK (length(identity) = 32),
    PRIMARY KEY (our_jid, their_id),
    FOREIGN KEY (our_jid) REFERENCES whatsmeow_device(jid) ON DELETE CASCADE ON UPDATE CASCADE
);

-- Other CREATE TABLE statements similar to the ones above.

ALTER TABLE whatsmeow_device ADD COLUMN adv_account_sig_key bytea CHECK (length(adv_account_sig_key) = 32);

UPDATE whatsmeow_device SET adv_account_sig_key = (
    SELECT identity FROM whatsmeow_identity_keys
    WHERE our_jid = whatsmeow_device.jid AND their_id = concat(split_part(whatsmeow_device.jid, '.', 1), ':0')
);

-- Other SQL statements for PostgreSQL or SQLite specific updates.

CREATE TABLE whatsmeow_message_secrets (
    our_jid TEXT,
    chat_jid TEXT,
    sender_jid TEXT,
    message_id TEXT,
    key bytea NOT NULL,
    PRIMARY KEY (our_jid, chat_jid, sender_jid, message_id),
    FOREIGN KEY (our_jid) REFERENCES whatsmeow_device(jid) ON DELETE CASCADE ON UPDATE CASCADE
);

But the real problem is here:
image

image

Apparantly cockroachdb doesn't runs update and delete on databases

from whatsmeow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.