about summary refs log tree commit homepage
path: root/lib/dtas/mlib/migrations/0001_initial.rb
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-11-22 01:05:05 +0000
committerEric Wong <e@80x24.org>2015-11-22 12:01:56 +0000
commit9581a01c87a7d8bf228bdec7d4f06bf8a3fed3ec (patch)
tree47d824524009eae8d13700cc1e2f5db8c6b4430f /lib/dtas/mlib/migrations/0001_initial.rb
parent2d1e3c9dcb40ccf2182045924530a804b578ba9f (diff)
downloaddtas-9581a01c87a7d8bf228bdec7d4f06bf8a3fed3ec.tar.gz
Eventually this will support searching and be the basis
of an mpd-compatible proxy in front of dtas-player
Diffstat (limited to 'lib/dtas/mlib/migrations/0001_initial.rb')
-rw-r--r--lib/dtas/mlib/migrations/0001_initial.rb42
1 files changed, 42 insertions, 0 deletions
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 <dtas-all@nongnu.org>
+# 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