Skip to content
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
3ef2525
initial rework for dual support of mysql and postgres, moved to use m…
s3inlc Nov 28, 2025
a98ef7d
added update for faking sqlx migration for existing mysql systems
s3inlc Nov 28, 2025
2b08347
set execution time of fake sqlx migration to 1
s3inlc Nov 28, 2025
7349062
setting sequences for all tables to avoid collisions in serials
s3inlc Nov 28, 2025
aa955b8
Merge remote-tracking branch 'origin/dev' into dba-migrations-and-pos…
s3inlc Nov 28, 2025
8ba2823
fixed sql query for migrations insert
s3inlc Nov 29, 2025
14f6874
removed selective update execution part and added one last force upgr…
s3inlc Nov 29, 2025
3492871
Merge remote-tracking branch 'origin/fix-update-order' into dba-migra…
s3inlc Nov 29, 2025
68a918a
prevent access to migrations dir
s3inlc Nov 29, 2025
cd9d006
made style and order consistent in files
s3inlc Nov 29, 2025
bd8ddb7
added checksum for existing upgrades
s3inlc Nov 29, 2025
c3c0209
updated github actions to run both systems
s3inlc Nov 29, 2025
73b1bdc
fixed github input
s3inlc Nov 29, 2025
bf3b2cd
removed double -f
s3inlc Nov 29, 2025
e06acae
input style fix
s3inlc Nov 29, 2025
9a26d1c
syntax fix
s3inlc Nov 29, 2025
4a076e6
fix workflow with -d on compose and postgres config
s3inlc Nov 29, 2025
445e1bc
fixed docker compose refer
s3inlc Nov 29, 2025
309bcf4
add exposed port
s3inlc Nov 29, 2025
18230a7
fixed postgres devcontainer compose
s3inlc Nov 29, 2025
ba5b1ac
execute legacy test framework only with mysql
s3inlc Nov 29, 2025
2d34f61
fixed path to initial sql
s3inlc Nov 29, 2025
9910401
fix second occurrence of initial sql
s3inlc Nov 29, 2025
fb70714
create separate compose files for the tests to avoid clashing with de…
s3inlc Nov 29, 2025
7861d4d
comment out unnecessary part
s3inlc Nov 29, 2025
d2059a5
really only call upgrade on mysql setups
s3inlc Nov 29, 2025
b17e8cb
no manual init for test needed
s3inlc Nov 29, 2025
69e8372
just only create api key, everything else should be created from basi…
s3inlc Nov 29, 2025
05682a9
set test user pass to default
s3inlc Nov 29, 2025
468456c
reversed hashtopolis test parameters to default
s3inlc Nov 29, 2025
342cc1b
create additional access group on tests
s3inlc Nov 29, 2025
19d5453
avoid creating multiple relations
s3inlc Nov 29, 2025
e6c0e98
deactivate legacy tests for now
s3inlc Nov 29, 2025
f8a5ffd
Merge remote-tracking branch 'origin/dev' into dba-migrations-and-pos…
s3inlc Dec 1, 2025
1ba1c09
removed order filter default on sum and minmax filters
s3inlc Dec 1, 2025
d029205
changed mysql specific LIKE BINARY to LIKE .. COLLATE C to achieve bi…
s3inlc Dec 1, 2025
7103ac9
differ between mysql and postgres in this very specific case of like …
s3inlc Dec 1, 2025
f124259
make the default access group created on migration to avoid primary k…
s3inlc Dec 1, 2025
364ca92
fixed order typo in like filter
s3inlc Dec 1, 2025
7650aef
removed debug output
s3inlc Dec 1, 2025
7f74e6d
Update src/dba/AbstractModelFactory.class.php
s3inlc Dec 1, 2025
b7e749f
added options list to github action
s3inlc Dec 2, 2025
c9ae11a
test running old test suite with changes
s3inlc Dec 2, 2025
3c4df12
definitely removing old legacy test in ci workflow
s3inlc Dec 2, 2025
5512458
Merge remote-tracking branch 'origin/dev' into dba-migrations-and-pos…
s3inlc Dec 2, 2025
d000b38
Merge remote-tracking branch 'origin/dev' into dba-migrations-and-pos…
s3inlc Dec 2, 2025
9f90283
renamed all indexes to be unique, restructured file to have alphabeti…
s3inlc Dec 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ services:
- CONTAINER_USER_CMD_PRE
- CONTAINER_USER_CMD_POST
environment:
HASHTOPOLIS_DB_TYPE: mysql
HASHTOPOLIS_DB_USER: hashtopolis
HASHTOPOLIS_DB_PASS: hashtopolis
HASHTOPOLIS_DB_HOST: hashtopolis-db-dev
Expand Down
51 changes: 51 additions & 0 deletions .devcontainer/docker-compose.postgres.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
version: "3.7"
services:
hashtopolis-server-dev:
container_name: hashtopolis-server-dev
build:
context: ..
target: hashtopolis-server-dev
args:
- CONTAINER_USER_CMD_PRE
- CONTAINER_USER_CMD_POST
environment:
HASHTOPOLIS_DB_TYPE: postgres
HASHTOPOLIS_DB_USER: hashtopolis
HASHTOPOLIS_DB_PASS: hashtopolis
HASHTOPOLIS_DB_HOST: hashtopolis-db-dev
HASHTOPOLIS_DB_DATABASE: hashtopolis
HASHTOPOLIS_APIV2_ENABLE: 1
depends_on:
- hashtopolis-db-dev
ports:
- "8080:80"
volumes:
# This is where VS Code should expect to find your project's source code
# and the value of "workspaceFolder" in .devcontainer/devcontainer.json
- ..:/var/www/html
- hashtopolis-server-dev:/usr/local/share/hashtopolis:Z
networks:
- hashtopolis_dev
hashtopolis-db-dev:
container_name: hashtopolis-db-dev
image: postgres:13
restart: always
ports:
- "5432:5432"
volumes:
- hashtopolis-db-dev:/var/lib/postgresql/data
environment:
POSTGRES_DB: hashtopolis
POSTGRES_USER: hashtopolis
POSTGRES_PASSWORD: hashtopolis
networks:
- hashtopolis_dev

volumes:
hashtopolis-db-dev:
hashtopolis-server-dev:

networks:
hashtopolis_dev:
# This network will also be used by the python-agent
name: hashtopolis_dev
17 changes: 12 additions & 5 deletions .github/actions/start-hashtopolis/action.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
name: Start Hashtopolis server
description: Starts application containers and waits for Hashtopolis to be ready.

inputs:
db_system:
description: "Used to set which DB system should be used"
required: true
default: "mysql"

runs:
using: "composite"
steps:
- name: Start application containers
working-directory: .devcontainer
run: docker compose up -d
shell: bash
- name: Install composer dependencies packages
run: docker exec hashtopolis-server-dev composer install --working-dir=/var/www/html/
working-directory: .github
run: docker compose -f docker-compose.${{ inputs.db_system }}.yml up -d
shell: bash
# should not be needed anymore as it is installed during build
# - name: Install composer dependencies packages
# run: docker exec hashtopolis-server-dev composer install --working-dir=/var/www/html/
# shell: bash
- name: Wait until entrypoint is finished and Hashtopolis is started
run: bash .github/scripts/await-hashtopolis-startup.sh
shell: bash
47 changes: 47 additions & 0 deletions .github/docker-compose.mysql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
version: "3.7"
services:
hashtopolis-server-dev:
container_name: hashtopolis-server-dev
build:
context: ..
target: hashtopolis-server-dev
args:
- CONTAINER_USER_CMD_PRE
- CONTAINER_USER_CMD_POST
environment:
HASHTOPOLIS_DB_TYPE: mysql
HASHTOPOLIS_DB_USER: hashtopolis
HASHTOPOLIS_DB_PASS: hashtopolis
HASHTOPOLIS_DB_HOST: hashtopolis-db-dev
HASHTOPOLIS_DB_DATABASE: hashtopolis
HASHTOPOLIS_APIV2_ENABLE: 1
depends_on:
- hashtopolis-db-dev
ports:
- "8080:80"
volumes:
- hashtopolis-server-dev:/usr/local/share/hashtopolis:Z
networks:
- hashtopolis_dev
hashtopolis-db-dev:
container_name: hashtopolis-db-dev
image: mysql:8.0
restart: always
ports:
- "3306:3306"
volumes:
- hashtopolis-db-dev:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: hashtopolis
MYSQL_DATABASE: hashtopolis
MYSQL_USER: hashtopolis
MYSQL_PASSWORD: hashtopolis
networks:
- hashtopolis_dev
volumes:
hashtopolis-db-dev:
hashtopolis-server-dev:

networks:
hashtopolis_dev:
name: hashtopolis_dev
47 changes: 47 additions & 0 deletions .github/docker-compose.postgres.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
version: "3.7"
services:
hashtopolis-server-dev:
container_name: hashtopolis-server-dev
build:
context: ..
target: hashtopolis-server-dev
args:
- CONTAINER_USER_CMD_PRE
- CONTAINER_USER_CMD_POST
environment:
HASHTOPOLIS_DB_TYPE: postgres
HASHTOPOLIS_DB_USER: hashtopolis
HASHTOPOLIS_DB_PASS: hashtopolis
HASHTOPOLIS_DB_HOST: hashtopolis-db-dev
HASHTOPOLIS_DB_DATABASE: hashtopolis
HASHTOPOLIS_APIV2_ENABLE: 1
depends_on:
- hashtopolis-db-dev
ports:
- "8080:80"
volumes:
- hashtopolis-server-dev:/usr/local/share/hashtopolis:Z
networks:
- hashtopolis_dev
hashtopolis-db-dev:
container_name: hashtopolis-db-dev
image: postgres:13
restart: always
ports:
- "5432:5432"
volumes:
- hashtopolis-db-dev:/var/lib/postgresql/data
environment:
POSTGRES_DB: hashtopolis
POSTGRES_USER: hashtopolis
POSTGRES_PASSWORD: hashtopolis
networks:
- hashtopolis_dev

volumes:
hashtopolis-db-dev:
hashtopolis-server-dev:

networks:
hashtopolis_dev:
name: hashtopolis_dev
12 changes: 10 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,23 @@ on:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- db_system: mysql
- db_system: postgres
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Start Hashtopolis server
uses: ./.github/actions/start-hashtopolis
with:
db_system: ${{ matrix.db_system }}
- name: Give Apache permissions on necessary directories # for the tests, only src/files and src/inc/utils/locks seem necessary
run: docker exec -u root hashtopolis-server-dev bash -c "chown -R www-data:www-data /var/www/html/src && chmod -R g+w /var/www/html/src"
- name: Run test suite
run: docker exec hashtopolis-server-dev php /var/www/html/ci/run.php -vmaster
# - name: Run test suite
# if: ${{ matrix.db_system == 'mysql' }} # the legacy is only supposed to work with mysql
# run: docker exec hashtopolis-server-dev php /var/www/html/ci/run.php -vmaster
- name: Test with pytest
run: docker exec hashtopolis-server-dev pytest /var/www/html/ci/apiv2
- name: Test if pytest is removing all test objects
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/docs-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
sudo apt-get install npm
- name: Start Hashtopolis server
uses: ./.github/actions/start-hashtopolis
with:
db_system: "mysql"
- name: Download newest apiv2 spec
run: |
wget http://localhost:8080/api/v2/openapi.json -P /tmp/
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ jobs:
sudo apt-get install php
sudo apt-get install -y lftp
sudo apt-get install nodejs
sudo apt-get install npm
sudo apt-get install npm
- name: Start Hashtopolis server
uses: ./.github/actions/start-hashtopolis
with:
db_system: "mysql"
- name: Download newest apiv2 spec
run: |
wget http://localhost:8080/api/v2/openapi.json -P /tmp/
Expand Down
10 changes: 8 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
FROM rust:1.91-trixie AS prebuild

RUN cargo install sqlx-cli --no-default-features --features native-tls,mysql,postgres

FROM alpine/git AS preprocess

COPY .gi[t] /.git
Expand Down Expand Up @@ -37,12 +41,12 @@ RUN apt-get update \
#
# Install git, procps, lsb-release (useful for CLI installs)
&& apt-get -y install git iproute2 procps lsb-release \
&& apt-get -y install mariadb-client \
&& apt-get -y install mariadb-client postgresql-client libpq-dev \
&& apt-get -y install libpng-dev \
&& apt-get -y install ssmtp \
\
# Install extensions (optional)
&& docker-php-ext-install pdo_mysql gd \
&& docker-php-ext-install pdo_mysql pgsql pdo_pgsql gd \
\
# Install Composer
&& curl -sS https://getcomposer.org/installer | php \
Expand Down Expand Up @@ -82,6 +86,8 @@ RUN mkdir -p ${HASHTOPOLIS_DOCUMENT_ROOT} \
&& chown www-data:www-data ${HASHTOPOLIS_BINARIES_PATH} \
&& chmod g+w ${HASHTOPOLIS_BINARIES_PATH}

COPY --from=prebuild /usr/local/cargo/bin/sqlx /usr/bin/

COPY --from=preprocess /HEA[D] ${HASHTOPOLIS_DOCUMENT_ROOT}/../.git/

# Install composer
Expand Down
17 changes: 8 additions & 9 deletions ci/HashtopolisTest.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ abstract class HashtopolisTest {
protected $user;
protected $apiKey;

const USER_PASS = "HG78Ghdfs87gh";
const USER_PASS = "hashtopolis";

const RUN_FULL = 0;
const RUN_FAST = 1;
Expand Down Expand Up @@ -70,28 +70,27 @@ public function init($version) {
global $PEPPER, $VERSION;

// drop old data and create empty DB
Factory::getAgentFactory()->getDB()->query("DROP DATABASE IF EXISTS hashtopolis");
/*Factory::getAgentFactory()->getDB()->query("DROP DATABASE IF EXISTS hashtopolis");
Factory::getAgentFactory()->getDB()->query("CREATE DATABASE hashtopolis");
Factory::getAgentFactory()->getDB()->query("USE hashtopolis");

// load DB
if ($version == "master") {
Factory::getAgentFactory()->getDB()->query(file_get_contents(dirname(__FILE__) ."/../src/install/hashtopolis.sql"));
Factory::getAgentFactory()->getDB()->query(file_get_contents(dirname(__FILE__) ."/../src/migrations/mysql/20251127000000_initial.sql"));
}
else {
Factory::getAgentFactory()->getDB()->query(file_get_contents(dirname(__FILE__) . "/files/db_" . $version . ".sql"));
}

sleep(1);
sleep(1);*/

// insert user and api key
$salt = Util::randomString(30);
/*$salt = Util::randomString(30);
$hash = Encryption::passwordHash(HashtopolisTest::USER_PASS, $salt);
$this->user = new User(null, 'testuser', '', $hash, $salt, 1, 0, 0, 0, 3600, AccessUtils::getOrCreateDefaultAccessGroup()->getId(), 0, '', '', '', '');
$this->user = Factory::getUserFactory()->save($this->user);
$accessGroup = new AccessGroupUser(null, 1, $this->user->getId());
Factory::getAccessGroupUserFactory()->save($accessGroup);
$this->apiKey = new ApiKey(null, 0, time() + 3600, 'mykey', 0, $this->user->getId(), 1);
$this->user = Factory::getUserFactory()->save($this->user);*/
AccessUtils::getOrCreateDefaultAccessGroup();
$this->apiKey = new ApiKey(null, 0, time() + 3600, 'mykey', 0, 1, 1);
$this->apiKey = Factory::getApiKeyFactory()->save($this->apiKey);
// $versionStore = new StoredValue("version", ($version == 'master') ? explode("+", $VERSION)[0] : $version);
// Factory::getStoredValueFactory()->save($versionStore);
Expand Down
2 changes: 1 addition & 1 deletion ci/server/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
try {
$db->query("CREATE DATABASE IF NOT EXISTS hashtopolis;");
$db->query("USE hashtopolis;");
$db->query(file_get_contents($envPath . "src/install/hashtopolis.sql"));
$db->query(file_get_contents($envPath . "src/migrations/mysql/20251127000000_initial.sql"));
}
catch (PDOException $e) {
fwrite(STDERR, "Failed to initialize database: " . $e->getMessage());
Expand Down
5 changes: 3 additions & 2 deletions docker-compose.yml → docker-compose.mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ services:
- hashtopolis:/usr/local/share/hashtopolis:Z
# - ./ssmtp.conf:/etc/ssmtp/ssmtp.conf
environment:
HASHTOPOLIS_DB_TYPE: mysql
HASHTOPOLIS_DB_USER: $MYSQL_USER
HASHTOPOLIS_DB_PASS: $MYSQL_PASSWORD
HASHTOPOLIS_DB_HOST: $HASHTOPOLIS_DB_HOST
HASHTOPOLIS_DB_DATABASE: $MYSQL_DATABASE
HASHTOPOLIS_ADMIN_USER: $HASHTOPOLIS_ADMIN_USER
HASHTOPOLIS_ADMIN_PASSWORD: $HASHTOPOLIS_ADMIN_PASSWORD
HASHTOPOLIS_APIV2_ENABLE: $HASHTOPOLIS_APIV2_ENABLE
HASHTOPOLIS_APIV2_ENABLE: $HASHTOPOLIS_APIV2_ENABLE
HASHTOPOLIS_FRONTEND_URLS: $HASHTOPOLIS_FRONTEND_URLS
depends_on:
- db
Expand All @@ -37,7 +38,7 @@ services:
environment:
HASHTOPOLIS_BACKEND_URL: $HASHTOPOLIS_BACKEND_URL
restart: always
depends_on:
depends_on:
- hashtopolis-backend
ports:
- 4200:80
Expand Down
45 changes: 45 additions & 0 deletions docker-compose.postgres.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
version: '3.7'
services:
hashtopolis-backend:
container_name: hashtopolis-backend
image: hashtopolis/backend:latest
restart: always
volumes:
- hashtopolis:/usr/local/share/hashtopolis:Z
# - ./ssmtp.conf:/etc/ssmtp/ssmtp.conf
environment:
HASHTOPOLIS_DB_TYPE: postgres
HASHTOPOLIS_DB_USER: $POSTGRES_USER
HASHTOPOLIS_DB_PASS: $POSTGRES_PASSWORD
HASHTOPOLIS_DB_HOST: $HASHTOPOLIS_DB_HOST
HASHTOPOLIS_DB_DATABASE: $POSTGRES_DATABASE
HASHTOPOLIS_ADMIN_USER: $HASHTOPOLIS_ADMIN_USER
HASHTOPOLIS_ADMIN_PASSWORD: $HASHTOPOLIS_ADMIN_PASSWORD
HASHTOPOLIS_APIV2_ENABLE: $HASHTOPOLIS_APIV2_ENABLE
depends_on:
- db
ports:
- 8080:80
db:
container_name: db
image: postgres:13
restart: always
volumes:
- db:/var/lib/postgresql/data
environment:
POSTGRES_DB: $POSTGRES_DATABASE
POSTGRES_USER: $POSTGRES_USER
POSTGRES_PASSWORD: $POSTGRES_PASSWORD
hashtopolis-frontend:
container_name: hashtopolis-frontend
image: hashtopolis/frontend:latest
environment:
HASHTOPOLIS_BACKEND_URL: $HASHTOPOLIS_BACKEND_URL
restart: always
depends_on:
- hashtopolis-backend
ports:
- 4200:80
volumes:
db:
hashtopolis:
Loading