Merge branch 'order-implementations' into 'master'
Order implementations See merge request pastebin.run/server!97
This commit is contained in:
commit
2b2792145b
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE implementations DROP COLUMN ordering;
|
|
@ -0,0 +1,5 @@
|
||||||
|
TRUNCATE implementation_wrappers;
|
||||||
|
DELETE FROM implementations;
|
||||||
|
|
||||||
|
ALTER TABLE implementations ADD COLUMN ordering int NOT NULL;
|
||||||
|
ALTER TABLE implementations ADD CONSTRAINT implementations_language_id_ordering_key UNIQUE (language_id, ordering);
|
|
@ -86,11 +86,14 @@ pub fn run(connection: &Connection) -> Result<(), Box<dyn Error>> {
|
||||||
.execute(connection)?;
|
.execute(connection)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for Implementation {
|
for (
|
||||||
label,
|
i,
|
||||||
identifier: implementation_identifier,
|
Implementation {
|
||||||
wrappers,
|
label,
|
||||||
} in implementations
|
identifier: implementation_identifier,
|
||||||
|
wrappers,
|
||||||
|
},
|
||||||
|
) in (1..).zip(implementations)
|
||||||
{
|
{
|
||||||
languages::table
|
languages::table
|
||||||
.filter(languages::identifier.eq(&languages_identifier))
|
.filter(languages::identifier.eq(&languages_identifier))
|
||||||
|
@ -98,16 +101,24 @@ pub fn run(connection: &Connection) -> Result<(), Box<dyn Error>> {
|
||||||
languages::language_id,
|
languages::language_id,
|
||||||
label.as_sql::<Text>(),
|
label.as_sql::<Text>(),
|
||||||
implementation_identifier.as_sql::<Text>(),
|
implementation_identifier.as_sql::<Text>(),
|
||||||
|
i.as_sql::<Integer>(),
|
||||||
))
|
))
|
||||||
.insert_into(implementations::table)
|
.insert_into(implementations::table)
|
||||||
.into_columns((
|
.into_columns((
|
||||||
implementations::language_id,
|
implementations::language_id,
|
||||||
implementations::label,
|
implementations::label,
|
||||||
implementations::identifier,
|
implementations::identifier,
|
||||||
|
implementations::ordering,
|
||||||
|
))
|
||||||
|
.on_conflict((
|
||||||
|
implementations::language_id,
|
||||||
|
implementations::identifier,
|
||||||
))
|
))
|
||||||
.on_conflict((implementations::language_id, implementations::identifier))
|
|
||||||
.do_update()
|
.do_update()
|
||||||
.set(implementations::label.eq(&label))
|
.set((
|
||||||
|
implementations::label.eq(&label),
|
||||||
|
implementations::ordering.eq(i),
|
||||||
|
))
|
||||||
.execute(connection)?;
|
.execute(connection)?;
|
||||||
for (
|
for (
|
||||||
i,
|
i,
|
||||||
|
|
|
@ -74,6 +74,7 @@ pub fn api_language(
|
||||||
let implementations = implementations::table
|
let implementations = implementations::table
|
||||||
.select((implementations::implementation_id, implementations::label))
|
.select((implementations::implementation_id, implementations::label))
|
||||||
.filter(implementations::language_id.eq(language.id))
|
.filter(implementations::language_id.eq(language.id))
|
||||||
|
.order(implementations::ordering)
|
||||||
.load(&connection)
|
.load(&connection)
|
||||||
.map_err(warp::reject::custom)?;
|
.map_err(warp::reject::custom)?;
|
||||||
let implementation_wrappers = ImplementationWrapper::belonging_to(&implementations)
|
let implementation_wrappers = ImplementationWrapper::belonging_to(&implementations)
|
||||||
|
|
|
@ -4,6 +4,7 @@ table! {
|
||||||
language_id -> Int4,
|
language_id -> Int4,
|
||||||
identifier -> Text,
|
identifier -> Text,
|
||||||
label -> Text,
|
label -> Text,
|
||||||
|
ordering -> Int4,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user