Skip to content

Commit 975f41d

Browse files
committed
fix: migrations
1 parent 285a950 commit 975f41d

File tree

7 files changed

+153
-107
lines changed

7 files changed

+153
-107
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
* Remove instance from redis even if using database
2020
* Unified integration session system so they don't overlap
2121
* Temporary fix for pictureUrl bug in groups
22+
* Fix on migrations
2223

2324
# 2.0.9-rc (2024-08-09 18:00)
2425

Docker/scripts/deploy_database.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ if [[ "$DATABASE_PROVIDER" == "postgresql" || "$DATABASE_PROVIDER" == "mysql" ]]
1010
export DATABASE_URL
1111
echo "Deploying migrations for $DATABASE_PROVIDER"
1212
echo "Database URL: $DATABASE_URL"
13-
rm -rf ./prisma/migrations
14-
cp -r ./prisma/$DATABASE_PROVIDER-migrations ./prisma/migrations
15-
npx prisma migrate deploy --schema ./prisma/$DATABASE_PROVIDER-schema.prisma
13+
# rm -rf ./prisma/migrations
14+
# cp -r ./prisma/$DATABASE_PROVIDER-migrations ./prisma/migrations
15+
npm run db:deploy
1616
if [ $? -ne 0 ]; then
1717
echo "Migration failed"
1818
exit 1
1919
else
2020
echo "Migration succeeded"
2121
fi
22-
npx prisma generate --schema ./prisma/$DATABASE_PROVIDER-schema.prisma
22+
npm run db:generate
2323
if [ $? -ne 0 ]; then
2424
echo "Prisma generate failed"
2525
exit 1

Docker/scripts/generate_database.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ if [[ "$DATABASE_PROVIDER" == "postgresql" || "$DATABASE_PROVIDER" == "mysql" ]]
1010
export DATABASE_URL
1111
echo "Generating database for $DATABASE_PROVIDER"
1212
echo "Database URL: $DATABASE_URL"
13-
npx prisma generate --schema=prisma/$DATABASE_PROVIDER-schema.prisma
13+
npm run db:generate
1414
if [ $? -ne 0 ]; then
1515
echo "Prisma generate failed"
1616
exit 1

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM node:20-alpine AS builder
33
RUN apk update && \
44
apk add git ffmpeg wget curl bash
55

6-
LABEL version="2.0.9-rc" description="Api to control whatsapp features through http requests."
6+
LABEL version="2.0.9" description="Api to control whatsapp features through http requests."
77
LABEL maintainer="Davidson Gomes" git="https://github.com/DavidsonGomes"
88
LABEL contact="contato@agenciadgcode.com"
99

@@ -18,6 +18,7 @@ COPY ./public ./public
1818
COPY ./prisma ./prisma
1919
COPY ./manager ./manager
2020
COPY ./.env.example ./.env
21+
COPY ./runWithProvider.js ./
2122

2223
COPY ./Docker ./Docker
2324

@@ -47,6 +48,7 @@ COPY --from=builder /evolution/manager ./manager
4748
COPY --from=builder /evolution/public ./public
4849
COPY --from=builder /evolution/.env ./.env
4950
COPY --from=builder /evolution/Docker ./Docker
51+
COPY --from=builder /evolution/runWithProvider.js ./runWithProvider.js
5052

5153
ENV DOCKER_ENV=true
5254

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "./dist/main.js",
66
"type": "commonjs",
77
"scripts": {
8-
"build": "tsup",
8+
"build": "tsup src/main.ts --out-dir dist",
99
"start": "tsnd -r tsconfig-paths/register --files --transpile-only ./src/main.ts",
1010
"start:prod": "node dist/main",
1111
"dev:server": "clear && tsnd -r tsconfig-paths/register --files --transpile-only --respawn --ignore-watch node_modules ./src/main.ts",

prisma/mysql-migrations/20240813153900_add_unique_index_for_remoted_jid_and_instance_in_contacts/migration.sql

Lines changed: 134 additions & 100 deletions
Large diffs are not rendered by default.

prisma/postgresql-migrations/20240811183328_add_unique_index_for_remoted_jid_and_instance_in_contacts/migration.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,14 @@
44
- A unique constraint covering the columns `[remoteJid,instanceId]` on the table `Contact` will be added. If there are existing duplicate values, this will fail.
55
66
*/
7+
-- Remove the duplicates
8+
DELETE FROM "Contact"
9+
WHERE ctid NOT IN (
10+
SELECT min(ctid)
11+
FROM "Contact"
12+
GROUP BY "remoteJid", "instanceId"
13+
);
14+
15+
716
-- CreateIndex
817
CREATE UNIQUE INDEX "Contact_remoteJid_instanceId_key" ON "Contact"("remoteJid", "instanceId");

0 commit comments

Comments
 (0)