Skip to content
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

Add experimental support for SQLite #1079

Merged
merged 3 commits into from
Jan 30, 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 Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ end

gem 'puma', '~> 5.6.2'
gem 'mysql2', '~> 0.5.3'
gem 'sqlite3'

gem 'nokogiri', '< 1.13' # Locked because of Ruby >= 2.6 dependency
gem 'thor', '<= 1.2.2' # Locked because of Ruby >= 2.6 dependency
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ GEM
spring-watcher-listen (2.0.1)
listen (>= 2.7, < 4.0)
spring (>= 1.2, < 3.0)
sqlite3 (1.4.4)
strong_migrations (0.7.9)
activerecord (>= 5)
sync (0.5.0)
Expand Down Expand Up @@ -360,6 +361,7 @@ DEPENDENCIES
spring
spring-commands-rspec
spring-watcher-listen (~> 2.0.0)
sqlite3
strong_migrations
terminal-table (~> 3.0)
thor (<= 1.2.2)
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,27 @@ Please view our [guide](docs/installation.md) to assist you in the RMT installat
sudo zypper in libxml2-devel libxslt-devel libmariadb-devel gcc
```
2. Install the ruby version specified in the `.ruby-version` [file](.ruby-version).
3. Install and start either the MariaDB or MySQL server:
3. Install and setup the database:

**Default: MariaDB or MySQL server**
```
sudo zypper in mariadb
sudo systemctl enable mariadb
sudo systemctl start mariadb
```
4. Log into the MariaDB or MySQL server as root and create the RMT database user:
Log into the MariaDB or MySQL server as root and create the RMT database user:
```
mysql -u root -p <<EOFF
GRANT ALL PRIVILEGES ON \`rmt%\`.* TO rmt@localhost IDENTIFIED BY 'rmt';
FLUSH PRIVILEGES;
EOFF
```

**Experimental: SQLite**

For development purposes it can be easier to run with SQLite, to avoid extra dependencies.
To run RMT with SQLite, switch the database adapter in `config/rmt.yml` to `sqlite3`.

5. Clone the RMT repository:
```
git clone git@github.com:SUSE/rmt.git
Expand Down
5 changes: 5 additions & 0 deletions bin/rmt-cli
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ end
db_config = RMT::Config.db_config
ActiveRecord::Base.establish_connection(db_config)

if ActiveRecord::Base.connection.adapter_name != "Mysql2"
warn "Running with experimental support for #{ActiveRecord::Base.connection.adapter_name}."
warn 'RMT is running without locking operations, make sure not to run it in multipe processes.'
digitaltom marked this conversation as resolved.
Show resolved Hide resolved
end

begin
RMT::CLI::Main.start(ARGV)
rescue Interrupt
Expand Down
1 change: 1 addition & 0 deletions lib/rmt/cli/base.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'rmt/lockfile'
require 'rmt/cli/decorators'
require 'etc'
require 'mysql2'

class RMT::CLI::Base < Thor

Expand Down
2 changes: 2 additions & 0 deletions lib/rmt/lockfile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ class RMT::Lockfile

class << self
def lock(lock_name = nil)
yield and return if ActiveRecord::Base.connection.adapter_name != 'Mysql2'

lock_name = ['rmt-cli', lock_name].compact.join('-')

is_lock_obtained = obtain_lock(lock_name)
Expand Down
Loading