Couldn't to rollback migrations: Value Error - django

I have tryed to roll back, cause have some migration conflicts, but it wrotes me:
ValueError: The field accounts.Ninja.id_team was declared with a lazy reference to 'mission.team', but app 'mission' doesn't provide model 'team'.
Trying python manage.py migrate accounts 0052.
[X] 0050_goal_id_ninja
[X] 0051_ninja_id_user
[X] 0052_alter_ninja_id_user
[ ] 0053_alter_ninja_id_user
[ ] 0054_remove_ninja_id_team
[ ] 0055_remove_ninja_id_user
[ ] 0056_remove_goal_id_ninja
[ ] 0057_ninja_id_user
[ ] 0058_remove_ninja_id_user
[ ] 0059_ninja_id_team_ninja_id_user
[ ] 0060_remove_ninja_id_user
[ ] 0061_delete_ninja
[ ] 0062_ninja
[ ] 0063_delete_ninja
[ ] 0064_ninja
[ ] 0065_ninja_id_team_ninja_id_user
[ ] 0066_remove_ninja_id_team
[ ] 0067_ninja_id_team
[ ] 0068_remove_ninja_id_team
[ ] 0069_ninja_id_team
Note. I have the model Team in mission app.

Related

How to use neptune-export

Can someone please list out a detailed stepwise process to export data from Neptune to S3(or local storage) in form of CSV.
I followed the doc(which seems to be the only resource available online), but it is not very clear.
TIA
The Neptune Export tool has many options that can be used to configure an export of both property graph and RDF data. The overall syntax of the command (if invoked via the command line) is:
NAME
neptune-export.sh export-pg - Export property graph from Neptune to CSV
or JSON.
SYNOPSIS
neptune-export.sh export-pg
[ --alb-endpoint <applicationLoadBalancerEndpoint> ]
[ --approx-edge-count <approxEdgeCount> ]
[ --approx-node-count <approxNodeCount> ]
[ {-b | --batch-size} <batchSize> ]
[ {-c | --config-file | --filter-config-file} <configFile> ]
[ --clone-cluster ]
[ --clone-cluster-instance-type <cloneClusterInstanceType> ]
[ --clone-cluster-replica-count <replicaCount> ]
[ {--cluster-id | --cluster | --clusterid} <clusterId> ]
[ {-cn | --concurrency} <concurrency> ]
[ {--config | --filter} <configJson> ] {-d | --dir} <directory>
[ --disable-ssl ] [ {-e | --endpoint} <endpoint>... ]
[ --edge-label-strategy <edgeLabelStrategy> ]
[ {-el | --edge-label} <edgeLabels>... ]
[ --escape-csv-headers ] [ --escape-newline ]
[ --exclude-type-definitions ] [ --export-id <exportId> ]
[ --format <format> ] [ --janus ]
[ --lb-port <loadBalancerPort> ] [ --limit <limit> ]
[ --log-level <log level> ]
[ --max-content-length <maxContentLength> ] [ --merge-files ]
[ --multi-value-separator <multiValueSeparator> ]
[ {-nl | --node-label} <nodeLabels>... ]
[ --nlb-endpoint <networkLoadBalancerEndpoint> ]
[ {-o | --output} <output> ] [ {-p | --port} <port> ]
[ --partition-directories <partitionDirectories> ]
[ --per-label-directories ] [ --profile <profiles>... ]
[ {-r | --range | --range-size} <rangeSize> ]
[ {--region | --stream-region} <region> ]
[ {-s | --scope} <scope> ] [ --serializer <serializer> ]
[ --skip <skip> ]
[ --stream-large-record-strategy <largeStreamRecordHandlingStrategy> ]
[ --stream-name <streamName> ] [ --strict-cardinality ]
[ {-t | --tag} <tag> ] [ --token-prefix <tokenPrefix> ]
[ --tokens-only <tokensOnly> ] [ --use-iam-auth ] [ --use-ssl ]
There are detailed instructions at the GitHub page for the tool that describe the alternative ways to export data. https://github.com/awslabs/amazon-neptune-tools/tree/master/neptune-export
If you still have questions I suggest making edits to the original question to clarify the precise challenges you have encountered.

AssetParameters changes when CDK codes updates for EKS deployed

CDK is used to deploy EKS in our company. A co-worker created a EKS cluster with CDK and then I pulled the CDK codes, modified something. Before deployment, I ran 'cdk diff' command and the result was shown many resources would be changed. Changes excluded what I modified were all AssetParameters as below.
# cdk diff
Stack eks-cluster
Parameters
[-] Parameter AssetParametersxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: {"Type":"String","Description":"S3 bucket for asset \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\""}
[-] Parameter AssetParametersxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: {"Type":"String","Description":"S3 key for asset version \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\""}
...
[+] Parameter AssetParameters/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/S3Bucket AssetParametersxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: {"Type":"String","Description":"S3 bucket for asset \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\""}
[+] Parameter AssetParameters/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/S3VersionKey AssetParametersxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: {"Type":"String","Description":"S3 key for asset version \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\""}
...
Resources
[~] AWS::CloudFormation::Stack #aws-cdk--aws-eks.ClusterResourceProvider.NestedStack/#aws-cdk--aws-eks.ClusterResourceProvider.NestedStackResource awscdkawseksClusterResourceProviderNestedStackawscdkawseksClusterResourceProviderNestedStackResourcexxxxx
[~] TemplateURL
[~] .Fn::Join:
## -7,7 +7,7 ##
[ ] },
[ ] "/",
[ ] {
[-] "Ref": "AssetParametersxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
[+] "Ref": "AssetParametersxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
[ ] },
[ ] "/",
[ ] {
## -17,7 +17,7 ##
[ ] "Fn::Split": [
[ ] "||",
[ ] {
[-] "Ref": "AssetParametersxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
[+] "Ref": "AssetParametersxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
[ ] }
[ ] ]
[ ] }
## -30,7 +30,7 ##
[ ] "Fn::Split": [
[ ] "||",
[ ] {
[-] "Ref": "AssetParametersxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
[+] "Ref": "AssetParametersxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
[ ] }
[ ] ]
[ ] }
[~] AWS::CloudFormation::Stack #aws-cdk--aws-eks.KubectlProvider.NestedStack/#aws-cdk--aws-eks.KubectlProvider.NestedStackResource awscdkawseksKubectlProviderNestedStackawscdkawseksKubectlProviderNestedStackResourcexxxxx
[~] Parameters
[+] Added: .referencetoeksclustereksAssetParametersxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxRef
[+] Added: .referencetoeksclustereksAssetParametersxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxRef
[-] Removed: .referencetoeksclustereksAssetParametersxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxRef
[-] Removed: .referencetoeksclustereksAssetParametersxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxRef
...
[~] TemplateURL
[~] .Fn::Join:
## -7,7 +7,7 ##
[ ] },
[ ] "/",
[ ] {
[-] "Ref": "AssetParametersxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
[+] "Ref": "AssetParametersxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
[ ] },
[ ] "/",
[ ] {
## -17,7 +17,7 ##
[ ] "Fn::Split": [
[ ] "||",
[ ] {
[-] "Ref": "AssetParametersxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
[+] "Ref": "AssetParametersxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
[ ] }
[ ] ]
[ ] }
## -30,7 +30,7 ##
[ ] "Fn::Split": [
[ ] "||",
[ ] {
[-] "Ref": "AssetParametersxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
[+] "Ref": "AssetParametersxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
[ ] }
[ ] ]
[ ] }
When the codes is deployed, is there no impact on the EKS cluster in running?
According to this issue this can happen, when the node version differs between machines:
https://github.com/aws/aws-cdk/issues/12427

"Django_content_type already exists" - after running migrate on server after database restore

I've migrated across to a server environment, and finally got everything working. The django project is rendering properly, but there seems to be a big problem with the migrations/database.
When I try and run migrations, I'm getting this error, which is affecting other things (like scripts I use to populate the project)
File "/home//.virtualenvs/versal/lib/python3.7/site-packages/djang o/db/backends/utils.py", line 83, in _execute
return self.cursor.execute(sql)
django.db.utils.ProgrammingError: relation "django_content_type" already exists
(versal) 06:18 ~/Versal/versal (master)$ Failing row contains (null, contenttypes, 0001_initial, 2019-04-29 06:11:02.087041+0
I tried to cleanup migrations and run them again, but this hasn't worked, as this is what 'showmigrations' shows.
accounts
[ ] 0001_initial
admin
[ ] 0001_initial
[ ] 0002_logentry_remove_auto_add
[ ] 0003_logentry_add_action_flag_choices
auth
[ ] 0001_initial
[ ] 0002_alter_permission_name_max_length
[ ] 0003_alter_user_email_max_length
[ ] 0004_alter_user_username_opts
[ ] 0005_alter_user_last_login_null
[ ] 0006_require_contenttypes_0002
[ ] 0007_alter_validators_add_error_messages
[ ] 0008_alter_user_username_max_length
[ ] 0009_alter_user_last_name_max_length
blog
[ ] 0001_initial
[ ] 0002_auto_20190225_1221
[ ] 0003_auto_20190225_1251
contenttypes
[ ] 0001_initial
[ ] 0002_remove_content_type_name
core
[ ] 0001_initial
[ ] 0002_auto_20190331_1730
[ ] 0003_auto_20190404_0920
curate
[ ] 0001_initial
[ ] 0002_item_video
[ ] 0003_set
[ ] 0004_auto_20190424_1620
[ ] 0005_item_tags
django_comments
[ ] 0001_initial
[ ] 0002_update_user_email_field_length
[ ] 0003_add_submit_date_index
podcast
[ ] 0001_initial
[ ] 0002_remove_episode_order
[ ] 0003_remove_show_ttl
[ ] 0004_auto_20170917_0503
[ ] 0005_episode_guid
[ ] 0006_auto_20170920_1833
[ ] 0007_auto_20170920_2212
[ ] 0008_auto_20170920_2212
[ ] 0009_auto_20170923_0129
[ ] 0010_auto_20170923_0131
[ ] 0011_episode_itunes_title
[ ] 0012_episode_type
[ ] 0013_episode_number
[ ] 0014_episode_season
[ ] 0015_show_type
[ ] 0016_auto_20170923_2000
[ ] 0017_auto_20170923_2133
[ ] 0018_auto_20170924_0609
[ ] 0019_auto_20170924_1839
[ ] 0020_auto_20171026_2121
[ ] 0021_auto_20171028_1742
[ ] 0022_remove_category_json
[ ] 0023_auto_20171121_2139
[ ] 0024_show_ttl
[ ] 0025_auto_20171211_0342
[ ] 0026_auto_20171211_0342
[ ] 0027_auto_20171211_0424
[ ] 0028_auto_20171211_0424
[ ] 0029_auto_20171211_0424
[ ] 0030_auto_20190426_1051
sessions
[ ] 0001_initial
sites
[ ] 0001_initial
[ ] 0002_alter_domain_unique
taggit
[ ] 0001_initial
[ ] 0002_auto_20150616_2121
[ ] 0003_taggeditem_add_unique_index
threadedcomments
[ ] 0001_initial
[ ] 0002_auto_20150521_2011
[ ] 0003_threadedcomment_newest_activity
I have those migrations on my local machine - I can add them back to where they out to be with a git push. But the problem persists.
My expected outcome is that I can makemigrations and migrate without errors each and every time...
If I run --fake-initial after make migrations, I get this:
django.db.utils.IntegrityError: null value in column "id" violates not-null constraint
DETAIL: Failing row contains (null, contenttypes, 0001_initial, 2019-04-29 06:48:55.697347+00).
I should also say, that if I run the command makemigrations, I get 'No Changes Detected', so in that sense Django is relatively happy.
I solved this issue on Django 2.2.7 or Django 3.0 hosted on Ubuntu 18.04 + Postgres 10.10 version.
# Restore the database in Postgres database (used pgAdmin tool for this)
(virtualenv) python manage.py loaddata dumpfile.json
# Dropping django_migrations table from the database (used pgAdmin tool for this)
(virtualenv) python manage.py makemigrations
(virtualenv) python manage.py migrate --fake
(virtualenv) python manage.py migrate
(virtualenv) python manage.py collectstatic
(virtualenv) python manage.py runserver 0.0.0.0:8000
Cheers!

Can't do regex matching in Swift

I am working on a Swift project and I need to use this regex to check email is valid or not but when the app start the checking the app crash and give me this error:
NSInternalInconsistencyException', reason: 'Can't do regex matching, reason: Can't open pattern U_REGEX_MISSING_CLOSE_BRACKET
This is my REGEX:
^(([^<>()[\\]\\.,;:\\s#\\\"]+(\\.[^<>()[\\]\\.,;:\\s#\\\"]+)*)|(\\\".+\\\"))#((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+[\\.]*)+[a-zA-Z]{2,}))$
Check unescaped brackets in your regex pattern:
let pattern
= "^(([^<>()[\\]\\.,;:\\s#\\\"]+(\\.[^<>()[\\]\\.,;:\\s#\\\"]+)*)|(\\\".+\\\"))"
// [ [ ] [ [ ]
+ "#((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+[\\.]*)+[a-zA-Z]{2,}))$"
// [ ] [ ] [ ] [ ] [ ] [ ] [ ]
You have some mismatching brackets [ ] in the first half of your pattern.
In some dialects of regex, you have no need to escape [ between [ and ], but in some other dialects, you need it.
Try adding some escapes to your regex:
let pattern
= "^(([^<>()\\[\\]\\.,;:\\s#\\\"]+(\\.[^<>()\\[\\]\\.,;:\\s#\\\"]+)*)|(\\\".+\\\"))"
// [ ^^ ] [ ^^ ]
+ "#((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+[\\.]*)+[a-zA-Z]{2,}))$"
// [ ] [ ] [ ] [ ] [ ] [ ] [ ]

Chaining grok filter patterns for logstash

I am trying to configure logstash to manage my various log sources, one of which is Mongrel2. The format used by Mongrel2 is tnetstring, where a log message will take the form
86:9:localhost,12:192.168.33.1,5:57089#10:1411396297#3:GET,1:/,8:HTTP/1.1,3:200#6:145978#]
I want to write my own grok patterns to extract certain fields from the above format. I received help on this question trying to extract the host. So if in grok-patterns I define
M2HOST ^(?:[^:]*\:){2}(?<hostname>[^,]*)
and then in the logstash conf specify
filter {
grok {
match => [ "message", "%{M2HOST}" ]
}
}
it works as expected. The problem I now have is I want to specify multiple patterns e.g. M2HOST, M2ADDR etc. I tried defining additional ones in the same grok-patterns file
M2HOST ^(?:[^:]*\:){2}(?<hostname>[^,]*)
M2ADDR ^(?:[^:]*\:){3}(?<address>[^,]*)
and changing the logstash conf
filter {
grok {
match => [ "message", "%{M2HOST} %{M2ADDR}" ]
}
}
but now I just get the error _grokparsefailure.
with your sample input from other question and with some guessing about the values names the full match would be:
(?:[^:]*:){2}(?<hostname>[^,]*)[^:]*:(?<address>[^,]*)[^:]*:(?<pid>[^#]*)[^:]*:(?<time>[^#]*)[^:]*:(?<method>[^,]*)[^:]*:(?<query>[^,]*)[^:]*:(?<protocol>[^,]*)[^:]*:(?<code>[^#]*)[^:]*:(?<bytes>[^#]*).*
Producing:
{
"hostname": [
[
"localhost"
]
],
"address": [
[
"192.168.33.1"
]
],
"pid": [
[
"57089"
]
],
"time": [
[
"1411396297"
]
],
"method": [
[
"GET"
]
],
"query": [
[
"/"
]
],
"protocol": [
[
"HTTP/1.1"
]
],
"code": [
[
"200"
]
],
"bytes": [
[
"145978"
]
]
}