8000 Add support for MySQL database servers by Floppy · Pull Request #2366 · manyfold3d/manyfold · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add support for MySQL database servers #2366

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ RUN apk add --no-cache \
s6-overlay \
alpine-sdk \
postgresql-dev \
mariadb-dev \
nodejs \
yarn \
xz \
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ gem "bootsnap", ">= 1.4.4", require: false
# Database adapters
gem "sqlite3", "~> 1.7"
group :production do
gem "mysql2", "~> 0.5.6"
gem "pg", "~> 1.5"
end

Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
< 10000 /span>
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ GEM
minitest (5.24.1)
msgpack (1.7.2)
mutex_m (0.2.0)
mysql2 (0.5.6)
nenv (0.3.0)
net-imap (0.4.13)
date
Expand Down Expand Up @@ -680,6 +681,7 @@ DEPENDENCIES
logstash-event (~> 1.2)
memoist (~> 0.16.2)
mittsu!
mysql2 (~> 0.5.6)
pg (~> 1.5)
public_suffix (~> 6.0)
puma (~> 6.4)
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/concerns/model_filters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ def process_filters
if @filters[:missingtag].presence || (@filters[:missingtag] && @filters[:library])
tag_regex_build = []
regexes = ((@filters[:missingtag] != "") ? [@filters[:missingtag]] : @models[0].library.tag_regex)
# work out regexp match syntax
regact = ApplicationRecord.connection.is_a?(ActiveRecord::ConnectionAdapters::SQLite3Adapter) ? "REGEXP" : "~"
# Regexp match syntax - postgres is different from MySQL and SQLite
regact = ApplicationRecord.connection.is_a?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter) ? "~" : "REGEXP"
regexes.each do |reg|
qreg = ActiveRecord::Base.connection.quote(reg)
tag_regex_build.push "(select count(*) from tags join taggings on tags.id=taggings.tag_id where tags.name #{regact} #{qreg} and taggings.taggable_id=models.id and taggings.taggable_type='Model')<1"
Expand Down
4 changes: 2 additions & 2 deletions bin/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if [ -f tmp/pids/server.pid ]; then
fi

# List of required variables to be set for modular database string generation
MODULAR_STRING_COMPONENTS="DATABASE_HOST DATABASE_USER DATABASE_PASSWORD DATABASE_NAME"
MODULAR_STRING_COMPONENTS="DATABASE_ADAPTER DATABASE_HOST DATABASE_USER DATABASE_PASSWORD DATABASE_NAME"

# Check if the required vars are set, if they are, generate the URL string, else exit with error code 1
echo "Executing database url substitution hack"
Expand All @@ -19,7 +19,7 @@ if [ -z ${DATABASE_URL} ]; then
fi
done
echo "Required variables check passed"
export DATABASE_URL="postgresql://${DATABASE_USER}:${DATABASE_PASSWORD}@${DATABASE_HOST}/${DATABASE_NAME}?pool=${DATABASE_CONNECTION_POOL:-5}" # DATABASE_CONNECTION_POOL is optional, hence it's absence from the required elements array. Defaults to 5
export DATABASE_URL="${DATABASE_ADAPTER}://${DATABASE_USER}:${DATABASE_PASSWORD}@${DATABASE_HOST}/${DATABASE_NAME}?pool=${DATABASE_CONNECTION_POOL:-5}" # DATABASE_CONNECTION_POOL is optional, hence it's absence from the required elements array. Defaults to 5
fi

echo "Preparing database..."
Expand Down
13 changes: 7 additions & 6 deletions docker-compose.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ services:
SECRET_KEY_BASE: a_nice_long_random_string
REDIS_URL: redis://redis:6379/1

# Database connection string
DATABASE_URL: postgresql://manyfold:password@db/manyfold?pool=5

# Database connection string; PostgreSQL is our recommended default
DATABASE_URL: postgresql://manyfold:password@postgres/manyfold?pool=5
# MySQL / MariaDB also works:
# DATABASE_URL: mysql2://manyfold:password@mysql/manyfold?pool=5
# You can also use SQLite if you don't want to run a separate database server.
# Make sure the specified path is on a persistent volume!
# DATABASE_URL: sqlite3:/config/manyfold.sqlite3?pool=5
Expand All @@ -26,15 +27,15 @@ services:
# For details of other optional environment variables, including features such
# as multiuser mode, visit https://manyfold.app/sysadmin/configuration.html
depends_on:
- db
- postgres
- redis
networks:
- manyfold
links:
- db
- postgres
- redis

db:
postgres:
image: postgres:15
volumes:
- db_data:/var/lib/postgresql/data
Expand Down
Loading
0