Перевод проекта на единую SQLite БД, WAL и обновление README для Windows
This commit is contained in:
16
config/db/migrate/20260303180000_create_cards.rb
Normal file
16
config/db/migrate/20260303180000_create_cards.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
Sequel.migration do
|
||||
change do
|
||||
create_table :cards do
|
||||
primary_key :id
|
||||
|
||||
column :name, String, null: false
|
||||
column :elixir_cost, Integer, null: false
|
||||
column :rarity, String
|
||||
column :type, String
|
||||
column :is_meta, Integer, default: 0
|
||||
|
||||
column :created_at, DateTime, null: false, default: Sequel::CURRENT_TIMESTAMP
|
||||
column :updated_at, DateTime, null: false, default: Sequel::CURRENT_TIMESTAMP
|
||||
end
|
||||
end
|
||||
end
|
||||
11
config/db/migrate/20260303200000_enable_sqlite_wal.rb
Normal file
11
config/db/migrate/20260303200000_enable_sqlite_wal.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
Sequel.migration do
|
||||
up do
|
||||
run "PRAGMA journal_mode = WAL;"
|
||||
run "PRAGMA synchronous = NORMAL;"
|
||||
end
|
||||
|
||||
down do
|
||||
run "PRAGMA journal_mode = DELETE;"
|
||||
run "PRAGMA synchronous = FULL;"
|
||||
end
|
||||
end
|
||||
14
config/db/structure.sql
Normal file
14
config/db/structure.sql
Normal file
@@ -0,0 +1,14 @@
|
||||
CREATE TABLE `schema_migrations`(`filename` varchar(255) NOT NULL PRIMARY KEY);
|
||||
CREATE TABLE `cards`(
|
||||
`id` integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`elixir_cost` integer NOT NULL,
|
||||
`rarity` varchar(255),
|
||||
`type` varchar(255),
|
||||
`is_meta` integer DEFAULT(0),
|
||||
`created_at` timestamp DEFAULT(datetime(CURRENT_TIMESTAMP, 'localtime')) NOT NULL,
|
||||
`updated_at` timestamp DEFAULT(datetime(CURRENT_TIMESTAMP, 'localtime')) NOT NULL
|
||||
);
|
||||
INSERT INTO schema_migrations (filename) VALUES
|
||||
('20260303180000_create_cards.rb'),
|
||||
('20260303200000_enable_sqlite_wal.rb');
|
||||
@@ -1,20 +0,0 @@
|
||||
warn "DB PROVIDER FILE LOADED"
|
||||
|
||||
ClashDeckGenerator2::App.register_provider :db do
|
||||
warn "DB PROVIDER REGISTERED"
|
||||
prepare do
|
||||
warn "DB PROVIDER PREPARE"
|
||||
require "hanami/db"
|
||||
end
|
||||
|
||||
start do
|
||||
warn "DB PROVIDER START"
|
||||
config = target["settings"].database_url
|
||||
|
||||
db = Hanami::DB.new(config)
|
||||
|
||||
register "db", db
|
||||
register "db.rom", db.rom
|
||||
register "db.gateway", db.gateway
|
||||
end
|
||||
end
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
module ClashDeckGenerator2
|
||||
class Settings < Hanami::Settings
|
||||
# Define your app settings here, for example:
|
||||
#
|
||||
# setting :my_flag, default: false, constructor: Types::Params::Bool
|
||||
setting :database_url, constructor: Types::String
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user