Skip to content

Commit 1943aa4

Browse files
authored
Merge pull request #690 from utopia-php/mongo-transactions
Mongo transactions
2 parents 2e3deb2 + b05eb72 commit 1943aa4

10 files changed

Lines changed: 265 additions & 56 deletions

File tree

‎composer.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"utopia-php/framework": "0.33.*",
4040
"utopia-php/cache": "0.13.*",
4141
"utopia-php/pools": "0.8.*",
42-
"utopia-php/mongo": "0.6.0"
42+
"utopia-php/mongo": "0.7.*"
4343
},
4444
"require-dev": {
4545
"fakerphp/faker": "1.23.*",

‎composer.lock‎

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎docker-compose.yml‎

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ services:
1717
- ./dev/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini
1818
- /var/run/docker.sock:/var/run/docker.sock
1919
- ./docker-compose.yml:/usr/src/code/docker-compose.yml
20-
#- ./vendor/utopia-php/mongo/src/Client.php:/usr/src/code/vendor/utopia-php/mongo/src/Client.php
2120
environment:
2221
PHP_IDE_CONFIG: serverName=tests
2322

@@ -85,35 +84,54 @@ services:
8584
- MYSQL_ROOT_PASSWORD=password
8685

8786
mongo:
88-
image: mongo:latest
87+
image: mongo:8.0.14
8988
container_name: utopia-mongo
89+
entrypoint: ["/entrypoint.sh"]
9090
networks:
9191
- database
9292
ports:
9393
- "9706:27017"
94+
volumes:
95+
- mongo-data:/data/db
96+
- ./tests/resources/mongo/mongo-keyfile:/tmp/keyfile:ro
97+
- ./tests/resources/mongo/entrypoint.sh:/entrypoint.sh:ro
9498
environment:
95-
MONGO_INITDB_DATABASE: utopia_testing
9699
MONGO_INITDB_ROOT_USERNAME: root
97100
MONGO_INITDB_ROOT_PASSWORD: password
98-
MONGO_INITDB_USERNAME: user
99-
MONGO_INITDB_PASSWORD: paswword
101+
MONGO_INITDB_DATABASE: utopia_testing
102+
healthcheck:
103+
test: |
104+
bash -c "
105+
if mongosh -u root -p password --authenticationDatabase admin --quiet --eval 'rs.status().ok' 2>/dev/null; then
106+
exit 0
107+
else
108+
mongosh -u root -p password --authenticationDatabase admin --quiet --eval \"
109+
rs.initiate({_id: 'rs0', members: [{_id: 0, host: 'localhost:27017'}]})
110+
\" 2>/dev/null || exit 1
111+
fi
112+
"
113+
interval: 10s
114+
timeout: 10s
115+
retries: 10
116+
start_period: 30s
100117

101118
mongo-express:
102119
image: mongo-express
103120
container_name: mongo-express
121+
depends_on:
122+
mongo:
123+
condition: service_healthy
104124
networks:
105125
- database
106126
ports:
107127
- "8083:8081"
108128
environment:
109-
ME_CONFIG_MONGODB_SERVER: mongo
110-
ME_CONFIG_MONGODB_ADMINUSERNAME: root
111-
ME_CONFIG_MONGODB_ADMINPASSWORD: password
129+
ME_CONFIG_MONGODB_URL: mongodb://root:password@mongo:27017/?authSource=admin&directConnection=true
112130
ME_CONFIG_BASICAUTH_USERNAME: admin
113131
ME_CONFIG_BASICAUTH_PASSWORD: admin
114132

115133
mysql:
116-
image: mysql:8.0.41
134+
image: mysql:8.0.43
117135
container_name: utopia-mysql
118136
networks:
119137
- database
@@ -129,7 +147,7 @@ services:
129147
- SYS_NICE
130148

131149
mysql-mirror:
132-
image: mysql:8.0.41
150+
image: mysql:8.0.43
133151
container_name: utopia-mysql-mirror
134152
networks:
135153
- database
@@ -145,20 +163,28 @@ services:
145163
- SYS_NICE
146164

147165
redis:
148-
image: redis:7.4.1-alpine3.20
166+
image: redis:8.2.1-alpine3.22
149167
container_name: utopia-redis
150168
ports:
151169
- "8708:6379"
152170
networks:
153171
- database
154172

155173
redis-mirror:
156-
image: redis:7.4.1-alpine3.20
174+
image: redis:8.2.1-alpine3.22
157175
container_name: utopia-redis-mirror
158176
ports:
159177
- "8709:6379"
160178
networks:
161179
- database
162180

181+
volumes:
182+
mongo-data:
183+
163184
networks:
164185
database:
186+
187+
secrets:
188+
mongo_keyfile:
189+
file: ./tests/resources/mongo/mongo-keyfile
190+

‎src/Database/Adapter.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,18 +1355,18 @@ abstract public function castingBefore(Document $collection, Document $document)
13551355
abstract public function castingAfter(Document $collection, Document $document): Document;
13561356

13571357
/**
1358-
* Is Mongo?
1358+
* Is internal casting supported?
13591359
*
13601360
* @return bool
13611361
*/
1362-
abstract public function isMongo(): bool;
1362+
abstract public function getSupportForInternalCasting(): bool;
13631363

13641364
/**
1365-
* Is internal casting supported?
1365+
* Is UTC casting supported?
13661366
*
13671367
* @return bool
13681368
*/
1369-
abstract public function getSupportForInternalCasting(): bool;
1369+
abstract public function getSupportForUTCCasting(): bool;
13701370

13711371
/**
13721372
* Set UTC Datetime

0 commit comments

Comments
 (0)