From 9581a01c87a7d8bf228bdec7d4f06bf8a3fed3ec Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 22 Nov 2015 01:05:05 +0000 Subject: introduce dtas-mlib for music library functions Eventually this will support searching and be the basis of an mpd-compatible proxy in front of dtas-player --- lib/dtas/mlib/migrations/0001_initial.rb | 42 ++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 lib/dtas/mlib/migrations/0001_initial.rb (limited to 'lib/dtas/mlib/migrations/0001_initial.rb') diff --git a/lib/dtas/mlib/migrations/0001_initial.rb b/lib/dtas/mlib/migrations/0001_initial.rb new file mode 100644 index 0000000..f147cbe --- /dev/null +++ b/lib/dtas/mlib/migrations/0001_initial.rb @@ -0,0 +1,42 @@ +# Copyright (C) 2015 all contributors +# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) + +Sequel.migration do + up do + create_table(:nodes) do + primary_key :id + String :name, null: false # encoding: binary, POSIX + Integer :ctime + foreign_key :parent_id, :nodes, null: false # parent dir + # >= 0: tlen of track, -2: ignore, -1: directory + Integer :tlen, null: false + unique [ :parent_id, :name ] + end + + create_table(:tags) do + primary_key :id + String :tag, null: false, unique: true # encoding: US-ASCII + end + + create_table(:vals) do + primary_key :id + String :val, null: false, unique: true # encoding: UTF-8 + end + + create_table(:comments) do + foreign_key :node_id, :nodes, null: false + foreign_key :tag_id, :tags, null: false + foreign_key :val_id, :vals, null: false + primary_key [ :node_id, :tag_id, :val_id ] + index :node_id + index [ :tag_id, :val_id ] + end + end + + down do + drop_table(:nodes) + drop_table(:tags) + drop_table(:vals) + drop_table(:comments) + end +end -- cgit v1.2.3-24-ge0c7