Skip to content

Commit

Permalink
Rename DB columns to keep naming consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
NelsonVides committed Feb 24, 2022
1 parent 817f7cf commit f83207a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions priv/mssql2012.sql
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ CREATE TABLE muc_registered(
-- but here we are limited by index size (900 bytes)
CREATE TABLE smart_markers (
lserver NVARCHAR(100) NOT NULL,
from_luser NVARCHAR(150) NOT NULL,
luser NVARCHAR(150) NOT NULL,
to_jid NVARCHAR(250) NOT NULL,
thread NVARCHAR(80) NOT NULL,
-- chat marker types:
Expand All @@ -699,7 +699,7 @@ CREATE TABLE smart_markers (
timestamp BIGINT NOT NULL,
CONSTRAINT pk_smart_markers PRIMARY KEY CLUSTERED(
lserver ASC,
from_luser ASC,
luser ASC,
to_jid ASC,
thread ASC,
type ASC
Expand Down
4 changes: 2 additions & 2 deletions priv/mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ CREATE TABLE mongoose_cluster_id (

CREATE TABLE smart_markers (
lserver VARBINARY(255) NOT NULL,
from_luser VARBINARY(1023) NOT NULL,
luser VARBINARY(1023) NOT NULL,
to_jid VARBINARY(1542) NOT NULL,
thread VARBINARY(250) NOT NULL,
-- 'R' - received
Expand All @@ -503,7 +503,7 @@ CREATE TABLE smart_markers (
type ENUM('R', 'D', 'A') NOT NULL,
msg_id VARBINARY(250) NOT NULL,
timestamp BIGINT NOT NULL,
PRIMARY KEY(lserver, from_luser, to_jid, thread, type)
PRIMARY KEY(lserver, luser, to_jid, thread, type)
) CHARACTER SET utf8mb4;

CREATE INDEX i_smart_markers USING BTREE ON smart_markers(to_jid, thread);
Expand Down
4 changes: 2 additions & 2 deletions priv/pg.sql
Original file line number Diff line number Diff line change
Expand Up @@ -456,13 +456,13 @@ CREATE TYPE chat_marker_type AS ENUM('R', 'D', 'A');

CREATE TABLE smart_markers (
lserver VARCHAR(250) NOT NULL,
from_luser VARCHAR(250) NOT NULL,
luser VARCHAR(250) NOT NULL,
to_jid VARCHAR(250) NOT NULL,
thread VARCHAR(250) NOT NULL,
type chat_marker_type NOT NULL,
msg_id VARCHAR(250) NOT NULL,
timestamp BIGINT NOT NULL,
PRIMARY KEY(lserver, from_luser, to_jid, thread, type)
PRIMARY KEY(lserver, luser, to_jid, thread, type)
);

CREATE INDEX i_smart_markers ON smart_markers(to_jid, thread);
Expand Down
10 changes: 5 additions & 5 deletions src/smart_markers/mod_smart_markers_rdbms.erl
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,24 @@
%%--------------------------------------------------------------------
-spec init(mongooseim:host_type(), gen_mod:module_opts()) -> ok.
init(HostType, _) ->
KeyFields = [<<"lserver">>, <<"from_luser">>, <<"to_jid">>, <<"thread">>, <<"type">>],
KeyFields = [<<"lserver">>, <<"luser">>, <<"to_jid">>, <<"thread">>, <<"type">>],
UpdateFields = [<<"msg_id">>, <<"timestamp">>],
InsertFields = KeyFields ++ UpdateFields,
rdbms_queries:prepare_upsert(HostType, smart_markers_upsert, smart_markers,
InsertFields, UpdateFields, KeyFields),
mongoose_rdbms:prepare(smart_markers_select, smart_markers,
[to_jid, thread, timestamp],
<<"SELECT lserver, from_luser, type, msg_id, timestamp FROM smart_markers "
<<"SELECT lserver, luser, type, msg_id, timestamp FROM smart_markers "
"WHERE to_jid = ? AND thread = ? AND timestamp >= ?">>),
mongoose_rdbms:prepare(markers_remove_domain, smart_markers,
[lserver], <<"DELETE FROM smart_markers WHERE lserver=?">>),
mongoose_rdbms:prepare(markers_remove_user, smart_markers,
[lserver, from_luser], <<"DELETE FROM smart_markers WHERE lserver=? AND from_luser=?">>),
[lserver, luser], <<"DELETE FROM smart_markers WHERE lserver=? AND luser=?">>),
mongoose_rdbms:prepare(markers_remove_to, smart_markers,
[to_jid], <<"DELETE FROM smart_markers WHERE to_jid=?">>),
mongoose_rdbms:prepare(markers_remove_to_for_user, smart_markers,
[lserver, from_luser, to_jid],
<<"DELETE FROM smart_markers WHERE lserver=? AND from_luser=? AND to_jid=?">>),
[lserver, luser, to_jid],
<<"DELETE FROM smart_markers WHERE lserver=? AND luser=? AND to_jid=?">>),
ok.

%%% @doc
Expand Down

0 comments on commit f83207a

Please sign in to comment.