u
This commit is contained in:
10
src/providers/sqlite3/queries/articleattributevalue.js
Normal file
10
src/providers/sqlite3/queries/articleattributevalue.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import * as source from '../../mssql/queries/articleattributevalue.js';
|
||||
import { translateQueries } from './translate.js';
|
||||
|
||||
const queries = translateQueries(source, 'articleattributevalue');
|
||||
export const {
|
||||
LIST_BY_ARTICLE_ID,
|
||||
DELETE_BY_ARTICLE_ID,
|
||||
INSERT_ROW,
|
||||
GET_VALUE_DETAIL,
|
||||
} = queries;
|
||||
10
src/providers/sqlite3/queries/articleproperty.js
Normal file
10
src/providers/sqlite3/queries/articleproperty.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import * as source from '../../mssql/queries/articleproperty.js';
|
||||
import { translateQueries } from './translate.js';
|
||||
|
||||
const queries = translateQueries(source, 'articleproperty');
|
||||
export const {
|
||||
LIST_BY_ARTICLE_ID,
|
||||
DELETE_BY_ARTICLE_ID,
|
||||
DELETE_BY_ARTICLE_AND_PROPERTY_ID,
|
||||
INSERT_ROW,
|
||||
} = queries;
|
||||
61
src/providers/sqlite3/queries/attributename.js
Normal file
61
src/providers/sqlite3/queries/attributename.js
Normal file
@@ -0,0 +1,61 @@
|
||||
import * as source from '../../mssql/queries/attributename.js';
|
||||
import { translateQueries } from './translate.js';
|
||||
|
||||
const queries = translateQueries(source, 'attributename');
|
||||
export const {
|
||||
LIST_IDS_BY_COMPANY,
|
||||
GET_BY_COMPANY_AND_NAME,
|
||||
GET_NEXT_SORT,
|
||||
CREATE,
|
||||
UPDATE_BY_ID,
|
||||
UPDATE_SORT,
|
||||
DELETE_BY_COMPANY_AND_ID,
|
||||
} = queries;
|
||||
|
||||
export const LIST_BY_COMPANY = `
|
||||
SELECT
|
||||
an.id,
|
||||
an.name,
|
||||
an.sort,
|
||||
an.exclusive,
|
||||
(
|
||||
SELECT COALESCE(json_group_array(json_object(
|
||||
'id', id,
|
||||
'value', value,
|
||||
'sort', sort
|
||||
)), '[]')
|
||||
FROM (
|
||||
SELECT av.id, av.value, av.sort
|
||||
FROM attributevalue av
|
||||
WHERE av.attribute_id = an.id
|
||||
ORDER BY av.sort ASC, av.id ASC
|
||||
)
|
||||
) AS valuesJson
|
||||
FROM attributename an
|
||||
WHERE an.company_id = @companyId
|
||||
ORDER BY an.sort ASC, an.id ASC
|
||||
`;
|
||||
|
||||
export const GET_BY_COMPANY_AND_ID = `
|
||||
SELECT
|
||||
an.id,
|
||||
an.company_id,
|
||||
an.name,
|
||||
an.sort,
|
||||
an.exclusive,
|
||||
(
|
||||
SELECT COALESCE(json_group_array(json_object(
|
||||
'id', id,
|
||||
'value', value,
|
||||
'sort', sort
|
||||
)), '[]')
|
||||
FROM (
|
||||
SELECT av.id, av.value, av.sort
|
||||
FROM attributevalue av
|
||||
WHERE av.attribute_id = an.id
|
||||
ORDER BY av.sort ASC, av.id ASC
|
||||
)
|
||||
) AS valuesJson
|
||||
FROM attributename an
|
||||
WHERE an.id = @id AND an.company_id = @companyId
|
||||
`;
|
||||
15
src/providers/sqlite3/queries/attributevalue.js
Normal file
15
src/providers/sqlite3/queries/attributevalue.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import * as source from '../../mssql/queries/attributevalue.js';
|
||||
import { translateQueries } from './translate.js';
|
||||
|
||||
const queries = translateQueries(source, 'attributevalue');
|
||||
export const {
|
||||
LIST_BY_ATTRIBUTE_ID,
|
||||
LIST_IDS_BY_ATTRIBUTE_ID,
|
||||
GET_BY_ID_AND_COMPANY,
|
||||
GET_BY_ATTRIBUTE_AND_VALUE,
|
||||
GET_NEXT_SORT,
|
||||
CREATE,
|
||||
UPDATE_BY_ID,
|
||||
UPDATE_SORT,
|
||||
DELETE_BY_ID,
|
||||
} = queries;
|
||||
15
src/providers/sqlite3/queries/propertyname.js
Normal file
15
src/providers/sqlite3/queries/propertyname.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import * as source from '../../mssql/queries/propertyname.js';
|
||||
import { translateQueries } from './translate.js';
|
||||
|
||||
const queries = translateQueries(source, 'propertyname');
|
||||
export const {
|
||||
LIST_BY_COMPANY,
|
||||
LIST_IDS_BY_COMPANY,
|
||||
GET_BY_COMPANY_AND_ID,
|
||||
GET_BY_COMPANY_AND_NAME,
|
||||
GET_NEXT_SORT,
|
||||
CREATE,
|
||||
UPDATE_BY_ID,
|
||||
UPDATE_SORT,
|
||||
DELETE_BY_COMPANY_AND_ID,
|
||||
} = queries;
|
||||
@@ -621,6 +621,65 @@ BEGIN
|
||||
END;
|
||||
`;
|
||||
|
||||
export const INIT_PROPERTYNAME = `
|
||||
CREATE TABLE IF NOT EXISTS propertyname (
|
||||
id INTEGER PRIMARY KEY,
|
||||
company_id INTEGER NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
sort INTEGER NOT NULL DEFAULT 0,
|
||||
FOREIGN KEY (company_id) REFERENCES company(id) ON DELETE CASCADE,
|
||||
UNIQUE (company_id, name)
|
||||
);
|
||||
`;
|
||||
|
||||
export const INIT_ARTICLEPROPERTY = `
|
||||
CREATE TABLE IF NOT EXISTS articleproperty (
|
||||
id INTEGER PRIMARY KEY,
|
||||
article_id INTEGER NOT NULL,
|
||||
property_id INTEGER NOT NULL,
|
||||
value TEXT NOT NULL,
|
||||
sort INTEGER NOT NULL DEFAULT 0,
|
||||
FOREIGN KEY (article_id) REFERENCES article(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (property_id) REFERENCES propertyname(id) ON DELETE CASCADE,
|
||||
UNIQUE (article_id, property_id)
|
||||
);
|
||||
`;
|
||||
|
||||
export const INIT_ATTRIBUTENAME = `
|
||||
CREATE TABLE IF NOT EXISTS attributename (
|
||||
id INTEGER PRIMARY KEY,
|
||||
company_id INTEGER NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
sort INTEGER NOT NULL DEFAULT 0,
|
||||
exclusive INTEGER NOT NULL DEFAULT 0,
|
||||
FOREIGN KEY (company_id) REFERENCES company(id) ON DELETE CASCADE,
|
||||
UNIQUE (company_id, name)
|
||||
);
|
||||
`;
|
||||
|
||||
export const INIT_ATTRIBUTEVALUE = `
|
||||
CREATE TABLE IF NOT EXISTS attributevalue (
|
||||
id INTEGER PRIMARY KEY,
|
||||
attribute_id INTEGER NOT NULL,
|
||||
value TEXT NOT NULL,
|
||||
sort INTEGER NOT NULL DEFAULT 0,
|
||||
FOREIGN KEY (attribute_id) REFERENCES attributename(id) ON DELETE CASCADE,
|
||||
UNIQUE (attribute_id, value)
|
||||
);
|
||||
`;
|
||||
|
||||
export const INIT_ARTICLEATTRIBUTEVALUE = `
|
||||
CREATE TABLE IF NOT EXISTS articleattributevalue (
|
||||
id INTEGER PRIMARY KEY,
|
||||
article_id INTEGER NOT NULL,
|
||||
attributevalue_id INTEGER NOT NULL,
|
||||
sort INTEGER NOT NULL DEFAULT 0,
|
||||
FOREIGN KEY (article_id) REFERENCES article(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (attributevalue_id) REFERENCES attributevalue(id) ON DELETE CASCADE,
|
||||
UNIQUE (article_id, attributevalue_id)
|
||||
);
|
||||
`;
|
||||
|
||||
/** DDL scripts in dependency order for SQLite schema initialization. */
|
||||
export const SCHEMA_SCRIPTS = [
|
||||
INIT_META,
|
||||
@@ -652,6 +711,11 @@ export const SCHEMA_SCRIPTS = [
|
||||
INIT_ARTICLENAME,
|
||||
INIT_PRICE,
|
||||
INIT_ARTICLE_SUPPLIER,
|
||||
INIT_PROPERTYNAME,
|
||||
INIT_ARTICLEPROPERTY,
|
||||
INIT_ATTRIBUTENAME,
|
||||
INIT_ATTRIBUTEVALUE,
|
||||
INIT_ARTICLEATTRIBUTEVALUE,
|
||||
INIT_MANIFEST,
|
||||
INIT_MANIFESTARTICLE,
|
||||
INIT_WAREHOUSE,
|
||||
|
||||
Reference in New Issue
Block a user