I upgraded my grails version from 3.8 to 4. In this step I upgraded the liquibase to 3.10.1.
Now my application won't startup any more. I get an error on this changeset:
changeSet(author: "prog1", id: "httpconnector-add-ignoreSSLVerification") {
addColumn(tableName: "inbound_connector") {
column(name: "ignoresslverification ", type: "boolean")
}
addColumn(tableName: "outbound_connector") {
column(name: "ignoresslverification ", type: "boolean")
}
sql("UPDATE outbound_connector set ignoresslverification = true")
sql("UPDATE inbound_connector set ignoresslverification = true")
}
I get this error:
liquibase.exception.MigrationFailedException: Migration failed for change set migrations/changelog.groovy::httpconnector-add-ignoreSSLVerification::ff:
Reason: liquibase.exception.DatabaseException: ERROR: column "ignoresslverification" of relation "outbound_connector" does not exist
Position: 31 [Failed SQL: (0) UPDATE outbound_connector set ignoresslverification = true]
What is the problem here?
I found the error: There is a blank at at column name. The old version ignored this, but the new version not.
Related
I am able to create an access review using this JSON:
{
"displayName": "Test-review-2 Group Membership Review",
"startDateTime":"2020-01-15T00:00:11.111Z",
"endDateTime":"2020-04-04T00:00:11.111Z",
"reviewedEntity":
{
"id": "f4b4b660-a6c2-4b1f-bb16-75f81432a63e"
},
"reviewerType" : "entityOwners",
"businessFlowTemplateId": "6e4f3d20-c5c3-407f-9695-8460952bcc68",
"description":"Access Review for the AAD group:Test-review-2(f4b4b660-a6c2-4b1f-bb16-75f81432a63e)",
"settings":
{
"mailNotificationsEnabled":true,
"remindersEnabled": true,
"justificationRequiredOnApproval":true,
"autoReviewEnabled":false,
"activityDurationInDays":365,
"autoApplyReviewResultsEnabled":true,
"accessRecommendationsEnabled":false,
"recurrenceSettings":
{
"recurrenceType":"onetime",
"recurrenceEndType":"occurrences",
"durationInDays":7,
"recurrenceCount":3
},
"autoReviewSettings":{
"notReviewedResult":"Approve"
}
}
}
If I change the recurrenceType to "weekly", I suddenly get an error:
Unhandled exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.AggregateException: One or more errors occurred. (Message: An error has occurred.
Inner error:
AdditionalData:
request-id: c1ba20d2-4fbb-45e4-ac89-a7f0ebb650ba
date: 2020-01-14T19:54:42
ClientRequestId: c1ba20d2-4fbb-45e4-ac89-a7f0ebb650ba
)
---> Status Code: InternalServerError
Microsoft.Graph.ServiceException: Message: An error has occurred.
Inner error:
AdditionalData:
request-id: c1ba20d2-4fbb-45e4-ac89-a7f0ebb650ba
date: 2020-01-14T19:54:42
ClientRequestId: c1ba20d2-4fbb-45e4-ac89-a7f0ebb650ba
I have looked through the documentation, and can't understand why.. Is there a dependent property I'm missing?
It looks like, in your example, recurrenceSettings is being passed in with the following values:
"recurrenceSettings":
{
"recurrenceType":"weekly",
"recurrenceEndType":"occurrences",
"durationInDays":7,
"recurrenceCount":3
},
"autoReviewSettings":{
"notReviewedResult":"Approve"
}
There are limits to the duration in days that one can specify for recurring reviews:
weekly -> 6
monthly -> 27
quarterly -> 80
annual -> 360
The durationInDays value that you’re passing for recurrenceType weekly is greater than the allowed maximum(6). Please try setting a value less than 7.
I am trying grand-stack-starter from neo4j and getting the below error with API module after I do all the graphql schema part. it complains that directive 'relation' and 'cypher'are unknown.
I reinstalled neo4j-graphql-js but didnt solve the problem.
Below is the error message
grand-stack-starter-api#0.0.1 start C:\Users\grand-stack-starter-master\api
nodemon --exec babel-node src/index.js
[nodemon] 1.18.9
[nodemon] to restart at any time, enter rs
[nodemon] watching: .
[nodemon] starting babel-node src/index.js
C:\Users\grand-stack-starter-master\api\node_modules\graphql\validation\validate.js:89
throw new Error(errors.map(function (error) {
^
Error: Unknown directive "relation".
Unknown directive "relation".
Unknown directive "cypher".
Unknown directive "cypher".
Unknown directive "relation".
Unknown directive "relation".
Unknown directive "relation".
Unknown directive "relation".
Unknown directive "relation".
Unknown directive "cypher".
at assertValidSDL (C:\Users\N19683\grand-stack-starter-master\api\node_modules\graphql\validation\validate.js:89:11)
at Object.buildASTSchema (C:\Users\N19683\grand-stack-starter-master\api\node_modules\graphql\utilities\buildASTSchema.js:67:34)
at Object.buildSchemaFromTypeDefinitions (C:\Users\N19683\grand-stack-starter-master\api\node_modules\graphql-tools\src\generate\buildSchemaFromTypeDefinitions.ts:43:32)
at makeExecutableSchema (C:\Users\N19683\grand-stack-starter-master\api\node_modules\graphql-tools\src\makeExecutableSchema.ts:52:16)
at Object.<anonymous> (C:/Users/N19683/grand-stack-starter-master/api/src/index.js:18:16)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at loader (C:\Users\N19683\grand-stack-starter-master\api\node_modules\babel-register\lib\node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (C:\Users\N19683\grand-stack-starter-master\api\node_modules\babel-register\lib\node.js:154:7)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
**
Below is the graphql-schema.js
import { neo4jgraphql } from "neo4j-graphql-js";
export const typeDefs = `
type User {
id: ID!
name: String
friends: [User] #relation(name: "FRIENDS", direction: "BOTH")
reviews: [Review] #relation(name: "WROTE", direction: "OUT")
avgStars: Float
#cypher(
statement: "MATCH (this)-[:WROTE]->(r:Review) RETURN toFloat(avg(r.stars))"
)
numReviews: Int
#cypher(statement: "MATCH (this)-[:WROTE]->(r:Review) RETURN COUNT(r)")
}
type Business {
id: ID!
name: String
address: String
city: String
state: String
reviews: [Review] #relation(name: "REVIEWS", direction: "IN")
categories: [Category] #relation(name: "IN_CATEGORY", direction: "OUT")
}
type Review {
id: ID!
stars: Int
text: String
date: Date
business: Business #relation(name: "REVIEWS", direction: "OUT")
user: User #relation(name: "WROTE", direction: "IN")
}
type Category {
name: ID!
businesses: [Business] #relation(name: "IN_CATEGORY", direction: "IN")
}
type Query {
usersBySubstring(substring: String): [User]
#cypher(
statement: "MATCH (u:User) WHERE u.name CONTAINS $substring RETURN u"
)
}
`
export const resolvers = {
Query: {
Users: neo4jgraphql,
Business: neo4jgraphql,
Category: neo4jgraphql,
Review: neo4jgraphql
}
};
index.js
import { typeDefs, resolvers } from "./graphql-schema";
import { ApolloServer, gql, makeExecutableSchema } from "apollo-server";
import { v1 as neo4j } from "neo4j-driver";
import { augmentSchema } from "neo4j-graphql-js";
import dotenv from "dotenv";
// set environment variables from ../.env
dotenv.config();
const schema = makeExecutableSchema({
typeDefs,
resolvers
});
const augmentedSchema = augmentSchema(schema);
const driver = neo4j.driver(
process.env.NEO4J_URI || "bolt://localhost:7689",
neo4j.auth.basic(
process.env.NEO4J_USER || "neo4j",
process.env.NEO4J_PASSWORD || "letmein"
)
);
const server = new ApolloServer({
context: { driver },
schema: augmentedSchema
});
server.listen(process.env.GRAPHQL_LISTEN_PORT, "0.0.0.0").then(({ url }) => {
console.log(`GraphQL API ready at ${url}`);
});
Can anyone please help to fix the issue! Thanks in advance
As noted in the docs
NOTE: Only use augmentSchema if you are working with an existing GraphQLSchema object. In most cases you should use makeAugmentedSchema which can construct the GraphQLSchema object from type definitions.
The error is occurring because you're attempting to use makeExecutableSchema to create your schema. The #relation and #cypher directives are used exclusively by neo4j-graphql. Since they're not actually defined as part of your schema, building your schema with makeExecutableSchema will result in an error just like using any other undefined directive.
You should just use makeAugmentedSchema instead:
const schema = makeAugmentedSchema({
typeDefs,
resolvers,
})
const driver = /* ... */
const server = new ApolloServer({
context: { driver },
schema,
})
I got the demo example from grand-stack and was able to start up graphql, start up the Neo4J sandbox and populate the test database using
npm run seedDb
However, when I try to write my own data entries to populate into a neo4j database, I cannot get the relation between nodes to work at all. The error message is the most non-useful message (and I believe it is from the apollo client, and is a status code 400 error). I simplified the code to the most simplest case to make it work, and it still does not. Here is the schema.graphql file:
type Patient {
id: ID!
name: String
reviews: [Review] #relation(name:"WROTE", direction:"OUT")
}
type Review {
id: ID!
stars: Int
text: String
date: Date
user: Patient #relation(name: "WROTE", direction: "IN")
}
and here is the seed-mutation.js file:
export default /* GraphQL */ `
mutation {
p1: CreatePatient(
id: "p1",
name: "John Doe 1"
) {
id
name
}
r1: CreateReview(id: "r1", stars: 4, text: "Great IPA selection!", date: { formatted: "2016-01-03"}) {
id
}
ar1: AddUserReviews(from: { id: "p1"}, to: { id: "r1" }) { from {id}}
}
`;
When I do "npm run seedDb", this yields the error message:
{ Error: Network error: Response not successful: Received status code 400
at new ApolloError (/Users/xxxx/Downloads/grand-stack-starter-master/api/node_modules/apollo-client/bundle.esm.js:60:28)
at Object.error (/Users/xxxx/Downloads/grand-stack-starter-master/api/node_modules/apollo-client/bundle.esm.js:1032:48)
at notifySubscription (/Users/xxxx/Downloads/grand-stack-starter-master/api/node_modules/zen-observable/lib/Observable.js:134:18)
at onNotify (/Users/xxxx/Downloads/grand-stack-starter-master/api/node_modules/zen-observable/lib/Observable.js:165:3)
at SubscriptionObserver.error (/Users/xxxx/Downloads/grand-stack-starter-master/api/node_modules/zen-observable/lib/Observable.js:224:7)
at /Users/xxxx/Downloads/grand-stack-starter-master/api/node_modules/apollo-link-http/src/httpLink.ts:184:20
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:228:7)
graphQLErrors: [],
networkError:
{ ServerError: Response not successful: Received status code 400
at Object.exports.throwServerError (/Users/xxxx/Downloads/grand-stack-starter-master/api/node_modules/apollo-link-http-common/src/index.ts:114:17)
at /Users/xxxx/Downloads/grand-stack-starter-master/api/node_modules/apollo-link-http-common/src/index.ts:145:11
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:228:7)
name: 'ServerError',
response:
Response {
size: 0,
timeout: 0,
[Symbol(Body internals)]: [Object],
[Symbol(Response internals)]: [Object] },
statusCode: 400,
result: { errors: [Array] } },
message: 'Network error: Response not successful: Received status code 400',
extraInfo: undefined }
I started with multiple complex codes and this is pretty much the most stripped down version. When I run the seedDB command after the seed-mutation.js file was modified to:
export default /* GraphQL */ `
mutation {
p1: CreatePatient(
id: "p1",
name: "John Doe 1"
) {
id
name
}
r1: CreateReview(id: "r1", stars: 4, text: "Great IPA selection!", date: { formatted: "2016-01-03"}) {
id
}
}
`;
the database gets populated, however the two nodes are not connected to each other, as expected (basically, this is the code with the AddUserReviews removed). How do I build the relation between the nodes through using graphql and seedDb? What am I missing?
You can use GraphQL Playground to inspect the GraphQL API (in the "Docs" tab):
to ensure the mutations you are calling have the correct name and arguments. From inspecting the schema, it looks like instead of AddUserReviews, you want AddPatientReviews?
I tried to run the "dbm-db-doc" script. It seems that the script is not working properly because it failed on a changelog that already been executed. This is the change:
changeSet(author: "Bernardo (generated)", id: "1436991688243-1") {
addColumn(tableName: "prepares_for_exam") {
column(name: "exam_id", type: "bigint")
}
grailsChange {
change {
sql.execute("UPDATE prepares_for_exam JOIN product ON prepares_for_exam.id = product.prepares_for_exam_id SET prepares_for_exam.exam_id = product.id")
}
rollback {
}
}
addNotNullConstraint(columnDataType: "bigint", tableName: "prepares_for_exam", columnName: "exam_id")
}
changeSet(author: "Bernardo (generated)", id: "1436991688243-32") {
dropColumn(columnName: "prepares_for_exam_id", tableName: "product")
}
And in the database, this changelog has been marked as "EXECUTED"
But when running the script it seems that the script wants to execute that changelog and fails because the column "product.prepares_for_exam_id" has already been dropped.
Full error:
|Starting dbm-db-doc for database root # jdbc:mysql://localhost:3306/xxx?autoReconnect=true&useUnicode=yes&characterEncoding=UTF-8
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'product.prepares_for_exam_id' in 'on clause'
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4237)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4169)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2617)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2778)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2828)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2777)
at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:949)
at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:795)
at Script1$_run_closure1_closure2_closure35_closure36.doCall(Script1.groovy:10)
at grails.plugin.databasemigration.GrailsChange.generateStatements(GrailsChange.groovy:159)
at liquibase.change.AbstractChange.getAffectedDatabaseObjects(AbstractChange.java:208)
at liquibase.changelog.visitor.DBDocVisitor.visit(DBDocVisitor.java:95)
at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:58)
at liquibase.Liquibase.generateDocumentation(Liquibase.java:740)
at DbmDbDoc$_run_closure1_closure2.doCall(DbmDbDoc:27)
at _DatabaseMigrationCommon_groovy$_run_closure2_closure11.doCall(_DatabaseMigrationCommon_groovy:59)
at grails.plugin.databasemigration.MigrationUtils.executeInSession(MigrationUtils.groovy:133)
at _DatabaseMigrationCommon_groovy$_run_closure2.doCall(_DatabaseMigrationCommon_groovy:51)
at DbmDbDoc$_run_closure1.doCall(DbmDbDoc:26)
at org.grails.ide.api.impl.GrailsConnectorImpl.executeCommand(GrailsConnectorImpl.java:160)
at org.grails.ide.eclipse.longrunning.process.GrailsProcess.run(GrailsProcess.java:130)
at org.grails.ide.eclipse.longrunning.process.GrailsProcess.main(GrailsProcess.java:93)
Error |
org.codehaus.groovy.grails.cli.ScriptExitException
Error |
So my question is:
Is there a bug in the "dbm-db-doc"-script or did I messed up something with the changeset?
I am answering my own question because I found the sollution:
It seems that the migration plugin keeps executing the "grailsChange" part every time although the changeSet has been executed already (I have no clue why... answers welcome!)
The sollution is to not use "grailsChange" and use the normal "sql" command instead. This is the sollution:
changeSet(author: "Bernardo (generated)", id: "1436991688243-1") {
addColumn(tableName: "prepares_for_exam") {
column(name: "exam_id", type: "bigint")
}
sql(""" UPDATE prepares_for_exam JOIN product ON prepares_for_exam.id = product.prepares_for_exam_id SET prepares_for_exam.exam_id = product.id """ )
addNotNullConstraint(columnDataType: "bigint", tableName: "prepares_for_exam", columnName: "exam_id")
}
I am trying to establish a many-to-many relationship between tables in sqlite using sequelize.
I want to add records to a join table (assign tasks to a user) and retrieve data from that table. For some reason, this does not work. Here is my code:
var orm = new Sequelize('db_name', '', '', {
dialect: 'sqlite',
storage: path.join(__dirname, 'db_name')
});
var User = orm.define('User', {
username: {type: Sequelize.STRING, unique: true}
});
var Task = orm.define('Task', {
id: {type: Sequelize.STRING, unique: true},
taskName: Sequelize.STRING
});
Task.hasMany(User);
User.hasMany(Task);
Task.sync();
User.sync();
Having read documentation (http://sequelize.readthedocs.org/en/latest/api/associations/#hasmanytarget-options), I expect that a join table TasksUsers should be created. I also expect .addTask method do be available. Then in another file I have:
db.User.findOrCreate({where:{username: "fakeUser"}}); //this seems to work
//some code to populate "Tasks" table;
db.User.find({where: {username: "fakeUser"}}).
complete(function(err,user){
console.log("user", user); //the user is found
db.Task.find({where: {id: "some_value"}}).
complete(function(err, task) {
console.log("task", task); //the task is found, so it works up to this point
user.addTask(task). //this line does not work
complete(function(err, results){
console.log("posting error", err);
});
})
});
I get an error "Possibly unhandled SequelizeDatabaseError: Error: SQLITE_ERROR: no such table: TasksUsers". The user.getTasks() method (without any arguments in the parentheses) does not work for the same reason.
Another observation: for testing purposes, I added these lines of code after establishing hasMany relationships:
orm.query("SELECT name FROM sqlite_master WHERE type = 'table'").success(function (res) {
console.log("tables", res);
})
The result that I get is tables [ 'Tasks', 'Users' ]
The versions: sequelize 2.0.0-rc2, sqlite3 3.0.4. I would be very grateful for any help.