sql: make schema for sqlite3

This commit is contained in:
King Kévin 2023-02-26 12:10:01 +01:00
parent f87025c5a6
commit b02832b8d3
2 changed files with 4 additions and 4 deletions

View File

@ -58,11 +58,11 @@ categories.each do |category|
puts category
table = "kicad_lib_" + category.downcase.gsub(/[- \/]/,"_")
view = "CREATE OR REPLACE VIEW #{table} AS "
view += "SELECT part.id, part.name, "
prop2view.each do |prop|
view += "SELECT part.id, part.name, part.description, "
(prop2view + dist2view).each do |prop|
view += "COALESCE(#{prop[:table]}1.#{prop[:property]},#{prop[:table]}2.#{prop[:property]}) AS #{prop[:property]}, "
end
view += "part.description FROM part "
view += "COALESCE(part.datasheet,parent.datasheet) AS datasheet FROM part "
view += "LEFT JOIN part AS parent ON parent.id = part.family "
(prop2view + dist2view).each do |prop|
view += "LEFT JOIN #{prop[:table]} AS #{prop[:table]}1 ON #{prop[:table]}1.part = part.id "

View File

@ -1,5 +1,5 @@
-- enable foreign key support in sqlite
--PRAGMA foreign_keys = ON;
PRAGMA foreign_keys = ON;
-- part manufacturer
CREATE TABLE IF NOT EXISTS manufacturer (